Add -h option to babeltrace-log
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 25 Jun 2011 07:15:12 +0000 (03:15 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 25 Jun 2011 07:15:12 +0000 (03:15 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-log.c

index 19cf3692a795ded50d645b7d5934788aaeb0412f..dfcfde71c9697b3a74341969d59e057219eb5ea4 100644 (file)
@@ -45,6 +45,7 @@ int babeltrace_debug, babeltrace_verbose;
 
 static char *s_outputname;
 static int s_timestamp;
+static int s_help;
 static uuid_t s_uuid;
 
 /* Metadata format string */
@@ -264,6 +265,11 @@ int parse_args(int argc, char **argv)
        for (i = 1; i < argc; i++) {
                if (!strcmp(argv[i], "-t"))
                        s_timestamp = 1;
+               else if (!strcmp(argv[i], "-h")) {
+                       s_help = 1;
+                       return 0;
+               } else if (argv[i][0] == '-')
+                       return -EINVAL;
                else
                        s_outputname = argv[i];
        }
@@ -281,10 +287,16 @@ int main(int argc, char **argv)
 
        ret = parse_args(argc, argv);
        if (ret) {
+               fprintf(stdout, "Error: invalid argument.\n");
                usage(stdout);
                goto error;
        }
 
+       if (s_help) {
+               usage(stdout);
+               exit(EXIT_SUCCESS);
+       }
+
        ret = mkdir(s_outputname, S_IRWXU|S_IRWXG);
        if (ret) {
                perror("mkdir");
This page took 0.024425 seconds and 4 git commands to generate.