Add a '--list-options' option to each command.
[lttng-tools.git] / src / bin / lttng / utils.c
index 25d463adf92ce49db5642ae488321ce5817116f4..635bf7734d244a0694135c5ac3b827644d72d9a8 100644 (file)
  */
 
 #include <stdlib.h>
+#include <ctype.h>
 
-#include <common/lttngerr.h>
+#include <common/error.h>
 
 #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);
+               }
+       }
+}
This page took 0.024327 seconds and 4 git commands to generate.