Implement --default-output option of create command
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 15 Jun 2016 20:59:51 +0000 (16:59 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 4 Jul 2016 19:42:28 +0000 (15:42 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/create.c

index 62607a0383311b065b44661d47d4f9a59ea13b1d..75edd2bee22db679925db1e88ecd382f7f6c4977 100644 (file)
@@ -53,12 +53,14 @@ static int opt_no_output;
 static int opt_snapshot;
 static unsigned int opt_live_timer;
 static bool opt_default_name;
+static bool opt_default_output;
 
 enum {
        OPT_HELP = 1,
        OPT_LIST_OPTIONS,
        OPT_LIVE_TIMER,
        OPT_DEFAULT_NAME,
+       OPT_DEFAULT_OUTPUT,
 };
 
 enum output_type {
@@ -92,6 +94,7 @@ static struct poptOption long_options[] = {
        {"shm-path",        0, POPT_ARG_STRING, &opt_shm_path, 0, 0, 0},
        {"template-path",        0, POPT_ARG_STRING, &opt_template_path, 0, 0, 0},
        {"default-name",    0, POPT_ARG_NONE, NULL, OPT_DEFAULT_NAME, 0, 0},
+       {"default-output",  0, POPT_ARG_NONE, NULL, OPT_DEFAULT_OUTPUT, 0, 0},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -264,6 +267,13 @@ static int validate_command_options(enum session_type type)
                ret = CMD_ERROR;
                goto error;
        }
+
+       if (opt_default_output && (opt_data_url || opt_ctrl_url || opt_url ||
+                       opt_output_path)) {
+               ERR("The --default-output option may not be used with the --output/-o, --set-url/-U, --ctrl-url/-C, or --data-url/-D options");
+               ret = CMD_ERROR;
+               goto error;
+       }
 error:
        return ret;
 }
@@ -1124,8 +1134,9 @@ static int create_session(void)
                 */
                base_ctrl_url = strdup(opt_ctrl_url);
                base_data_url = strdup(opt_data_url);
-       } else if (!(opt_no_output || base_output_type == OUTPUT_NONE ||
-                               base_url || base_ctrl_url || base_data_url)) {
+       } else if (opt_default_output || !(opt_no_output ||
+                       base_output_type == OUTPUT_NONE || base_url ||
+                       base_ctrl_url || base_data_url)) {
                /* Generate default output depending on the session type */
                switch (base_session_type) {
                case SESSION_NORMAL:
@@ -1481,6 +1492,9 @@ int cmd_create(int argc, const char **argv)
                case OPT_DEFAULT_NAME:
                        opt_default_name = true;
                        break;
+               case OPT_DEFAULT_OUTPUT:
+                       opt_default_output = true;
+                       break;
                default:
                        ret = CMD_UNDEFINED;
                        goto end;
This page took 0.02792 seconds and 5 git commands to generate.