Add --list-commands option to the snapshot command
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 13 Aug 2013 20:26:23 +0000 (16:26 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 26 Aug 2013 18:18:01 +0000 (14:18 -0400)
It lists snapshot sub-commands. This involves moving list_commands
to utils so that commands can use it.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/commands/snapshot.c
src/bin/lttng/lttng.c
src/bin/lttng/utils.c
src/bin/lttng/utils.h

index dd1137baa157c0c051256f4a71934a1de1ba3301..a357730d008444d1d1b1db4ffc36dc40637bd19e 100644 (file)
@@ -50,6 +50,7 @@ enum {
        OPT_HELP = 1,
        OPT_LIST_OPTIONS,
        OPT_MAX_SIZE,
+       OPT_LIST_COMMANDS,
 };
 
 static struct poptOption snapshot_opts[] = {
@@ -61,6 +62,7 @@ static struct poptOption snapshot_opts[] = {
        {"name",         'n', POPT_ARG_STRING, &opt_output_name, 0, 0, 0},
        {"max-size",     'm', POPT_ARG_STRING, 0, OPT_MAX_SIZE, 0, 0},
        {"list-options",   0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
+       {"list-commands",  0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -440,6 +442,9 @@ int cmd_snapshot(int argc, const char **argv)
                case OPT_LIST_OPTIONS:
                        list_cmd_options(stdout, snapshot_opts);
                        goto end;
+               case OPT_LIST_COMMANDS:
+                       list_commands(actions, stdout);
+                       goto end;
                case OPT_MAX_SIZE:
                {
                        uint64_t val;
index 5755db6379daa5466cd1542a6709bfb97318e724..dc9dd9241b9847eb12466fefdefa8120314321ad 100644 (file)
@@ -150,25 +150,6 @@ static void list_options(FILE *ofp)
        }
 }
 
-/*
- *  list_commands
- *
- *  List commands line by line. This is mostly for bash auto completion and to
- *  avoid difficult parsing.
- */
-static void list_commands(FILE *ofp)
-{
-       int i = 0;
-       struct cmd_struct *cmd = NULL;
-
-       cmd = &commands[i];
-       while (cmd->name != NULL) {
-               fprintf(ofp, "%s\n", cmd->name);
-               i++;
-               cmd = &commands[i];
-       }
-}
-
 /*
  * clean_exit
  */
@@ -466,7 +447,7 @@ static int parse_args(int argc, char **argv)
                        ret = 0;
                        goto end;
                case OPT_DUMP_COMMANDS:
-                       list_commands(stdout);
+                       list_commands(commands, stdout);
                        ret = 0;
                        goto end;
                default:
index 6041655ddda0f6eb42de5b829cb29688c11f1a24..e40c3fd708e3d4c3d18bfcc7a0e8be1b7ee89ea3 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "conf.h"
 #include "utils.h"
+#include "command.h"
 
 /*
  *  get_session_name
@@ -56,6 +57,24 @@ error:
        return NULL;
 }
 
+/*
+ *  list_commands
+ *
+ *  List commands line by line. This is mostly for bash auto completion and to
+ *  avoid difficult parsing.
+ */
+void list_commands(struct cmd_struct *commands, FILE *ofp)
+{
+       int i = 0;
+       struct cmd_struct *cmd = NULL;
+
+       cmd = &commands[i];
+       while (cmd->name != NULL) {
+               fprintf(ofp, "%s\n", cmd->name);
+               i++;
+               cmd = &commands[i];
+       }
+}
 
 /*
  * list_cmd_options
index 57bec1250fe1ea237b0e6913b0160bd83b3c646c..fb973caa5f44238bb78da41007ae2839157f776f 100644 (file)
 
 #include <popt.h>
 
+struct cmd_struct;
+
 char *get_session_name(void);
+void list_commands(struct cmd_struct *commands, FILE *ofp);
 void list_cmd_options(FILE *ofp, struct poptOption *options);
 
 /*
This page took 0.027749 seconds and 4 git commands to generate.