From: Jonathan Rajotte Date: Thu, 27 Aug 2020 19:56:43 +0000 (-0400) Subject: Implement list_cmd_options_argpar X-Git-Tag: v2.13.0-rc1~324 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b083f028413002a7d18f2e7b93680e1bb767a259;p=lttng-tools.git Implement list_cmd_options_argpar Small utility allowing the printing of argpar options. Signed-off-by: Simon Marchi Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: Ic39ce6f7eebfc3cb1d3fb12873862e9edd563dc6 --- diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index 28b007b24..b363cfed0 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -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 diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h index 28ebc51a8..a51c8579a 100644 --- a/src/bin/lttng/utils.h +++ b/src/bin/lttng/utils.h @@ -9,6 +9,7 @@ #define _LTTNG_UTILS_H #include +#include "common/argpar/argpar.h" #include @@ -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).