Implement list_cmd_options_argpar
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 27 Aug 2020 19:56:43 +0000 (15:56 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 12 Feb 2021 23:07:45 +0000 (18:07 -0500)
Small utility allowing the printing of argpar options.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic39ce6f7eebfc3cb1d3fb12873862e9edd563dc6

src/bin/lttng/utils.c
src/bin/lttng/utils.h

index 28b007b2402889d8782473033eee8119258ebc73..b363cfed04521fad884a9235090e5f54f881ade3 100644 (file)
@@ -128,6 +128,24 @@ void list_cmd_options(FILE *ofp, struct poptOption *options)
        }
 }
 
+/*
+ * Same as list_cmd_options, but for options specified for argpar.
+ */
+void list_cmd_options_argpar(FILE *ofp, const struct argpar_opt_descr *options)
+{
+       int i;
+
+       for (i = 0; options[i].long_name != NULL; i++) {
+               const struct argpar_opt_descr *option = &options[i];
+
+               fprintf(ofp, "--%s\n", option->long_name);
+
+               if (isprint(option->short_name)) {
+                       fprintf(ofp, "-%c\n", option->short_name);
+               }
+       }
+}
+
 /*
  * fls: returns the position of the most significant bit.
  * Returns 0 if no bit is set, else returns the position of the most
index 28ebc51a8fe5c829e37dfcbb033c9fdb3f37cd04..a51c8579a8e42d7de4549f44d0792ae0a5971f25 100644 (file)
@@ -9,6 +9,7 @@
 #define _LTTNG_UTILS_H
 
 #include <popt.h>
+#include "common/argpar/argpar.h"
 
 #include <lttng/lttng.h>
 
@@ -23,6 +24,7 @@ char *get_session_name(void);
 char *get_session_name_quiet(void);
 void list_commands(struct cmd_struct *commands, FILE *ofp);
 void list_cmd_options(FILE *ofp, struct poptOption *options);
+void list_cmd_options_argpar(FILE *ofp, const struct argpar_opt_descr *options);
 
 /*
  * Return the minimum order for which x <= (1UL << order).
This page took 0.0294 seconds and 5 git commands to generate.