Fix: error out on leftover arguments
[lttng-tools.git] / src / bin / lttng / commands / disable_channels.c
index a8bfa5deaeda8ad759eb82fee2f31412d34ab291..936884e1fc430c79da4ec98b79e24ff8f555fdc3 100644 (file)
@@ -34,6 +34,12 @@ static int opt_kernel;
 static char *opt_session_name;
 static int opt_userspace;
 
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-disable-channel.1.h>
+;
+#endif
+
 enum {
        OPT_HELP = 1,
        OPT_USERSPACE,
@@ -53,22 +59,6 @@ static struct poptOption long_options[] = {
        {0, 0, 0, 0, 0, 0, 0}
 };
 
-/*
- * usage
- */
-static void usage(FILE *ofp)
-{
-       fprintf(ofp, "usage: lttng disable-channel NAME[,NAME2,...] (-k | -u) [OPTIONS]\n");
-       fprintf(ofp, "\n");
-       fprintf(ofp, "Options:\n");
-       fprintf(ofp, "  -h, --help               Show this help\n");
-       fprintf(ofp, "      --list-options       Simple listing of options\n");
-       fprintf(ofp, "  -s, --session NAME       Apply to session name\n");
-       fprintf(ofp, "  -k, --kernel             Apply to the kernel tracer\n");
-       fprintf(ofp, "  -u, --userspace          Apply to the user-space tracer\n");
-       fprintf(ofp, "\n");
-}
-
 static int mi_partial_channel_print(char *channel_name, unsigned int enabled,
                int success)
 {
@@ -226,6 +216,7 @@ int cmd_disable_channels(int argc, const char **argv)
        int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
        static poptContext pc;
        char *session_name = NULL;
+       const char *leftover = NULL;
 
        pc = poptGetContext(NULL, argc, argv, long_options, 0);
        poptReadDefaultConfig(pc, 0);
@@ -242,7 +233,6 @@ int cmd_disable_channels(int argc, const char **argv)
                        list_cmd_options(stdout, long_options);
                        goto end;
                default:
-                       usage(stderr);
                        ret = CMD_UNDEFINED;
                        goto end;
                }
@@ -257,7 +247,13 @@ int cmd_disable_channels(int argc, const char **argv)
        opt_channels = (char*) poptGetArg(pc);
        if (opt_channels == NULL) {
                ERR("Missing channel name(s).\n");
-               usage(stderr);
+               ret = CMD_ERROR;
+               goto end;
+       }
+
+       leftover = poptGetArg(pc);
+       if (leftover) {
+               ERR("Unknown argument: %s", leftover);
                ret = CMD_ERROR;
                goto end;
        }
This page took 0.025394 seconds and 5 git commands to generate.