X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Futils.c;h=635bf7734d244a0694135c5ac3b827644d72d9a8;hp=e993f0f7231c8c5b71ef6363e37598f5ba4bda5a;hb=679b4943c3b0f451e7f4fbcd804dd8a7a679e253;hpb=db7586006bc1a2b9057a2c108bf1e7d20fd6903f diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index e993f0f72..635bf7734 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -17,10 +17,12 @@ */ #include +#include #include #include "conf.h" +#include "utils.h" /* * get_session_name @@ -48,3 +50,26 @@ error: DBG("Session name found: %s", session_name); return session_name; } + + +/* + * list_cmd_options + * + * Prints a simple list of the options available to a command. This is intended + * to be easily parsed for bash completion. + */ +void list_cmd_options(FILE *ofp, struct poptOption *options) +{ + int i; + struct poptOption *option = NULL; + + for (i = 0; options[i].longName != NULL; i++) { + option = &options[i]; + + fprintf(ofp, "--%s\n", option->longName); + + if (isprint(option->shortName)) { + fprintf(ofp, "-%c\n", option->shortName); + } + } +}