Add --version command-line option to lttng.
authorStefan Seefeld <stefan@codesourcery.com>
Sat, 11 May 2013 12:50:37 +0000 (08:50 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 13 May 2013 20:38:52 +0000 (16:38 -0400)
Signed-off-by: Stefan Seefeld <stefan@codesourcery.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/lttng.c

index 79a28ba82da1c94eb4028a874e03d1a2e654224c..c5198bda1b144784e1e42670458491d6fa22bec2 100644 (file)
@@ -47,6 +47,7 @@ enum {
 
 /* Getopt options. No first level command. */
 static struct option long_options[] = {
+       {"version",          0, NULL, 'V'},
        {"help",             0, NULL, 'h'},
        {"group",            1, NULL, 'g'},
        {"verbose",          0, NULL, 'v'},
@@ -85,6 +86,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Options:\n");
+       fprintf(ofp, "  -V, --version              Show version\n");
        fprintf(ofp, "  -h, --help                 Show this help\n");
        fprintf(ofp, "      --list-options         Simple listing of lttng options\n");
        fprintf(ofp, "      --list-commands        Simple listing of lttng commands\n");
@@ -116,6 +118,12 @@ static void usage(FILE *ofp)
        fprintf(ofp, "See http://lttng.org for updates, bug reports and news.\n");
 }
 
+static void version(FILE *ofp)
+{
+       fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME"\n",
+                       progname);
+}
+
 /*
  *  list_options
  *
@@ -426,8 +434,12 @@ static int parse_args(int argc, char **argv)
                clean_exit(EXIT_FAILURE);
        }
 
-       while ((opt = getopt_long(argc, argv, "+hnvqg:", long_options, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "+Vhnvqg:", long_options, NULL)) != -1) {
                switch (opt) {
+               case 'V':
+                       version(stdout);
+                       ret = 0;
+                       goto end;
                case 'h':
                        usage(stdout);
                        ret = 0;
This page took 0.029998 seconds and 4 git commands to generate.