Implement create command --default-name option
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 15 Jun 2016 20:58:54 +0000 (16:58 -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 caa12d93e9e5e10c9efa609ea15e79aa840a926b..62607a0383311b065b44661d47d4f9a59ea13b1d 100644 (file)
@@ -52,11 +52,13 @@ static int opt_no_consumer;
 static int opt_no_output;
 static int opt_snapshot;
 static unsigned int opt_live_timer;
+static bool opt_default_name;
 
 enum {
        OPT_HELP = 1,
        OPT_LIST_OPTIONS,
        OPT_LIVE_TIMER,
+       OPT_DEFAULT_NAME,
 };
 
 enum output_type {
@@ -89,6 +91,7 @@ static struct poptOption long_options[] = {
        {"live",            0, POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, OPT_LIVE_TIMER, 0, 0},
        {"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},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -256,6 +259,11 @@ static int validate_command_options(enum session_type type)
                }
        }
 
+       if (opt_session_name && opt_default_name) {
+               ERR("A session name must not be provided if the --default-name option is used");
+               ret = CMD_ERROR;
+               goto error;
+       }
 error:
        return ret;
 }
@@ -1053,7 +1061,7 @@ static int create_session(void)
                        goto error;
                }
                DBG("Session name from command option set to %s", base_session_name);
-       } else if (base_session_name) {
+       } else if (base_session_name && !opt_default_name) {
                printed_bytes = asprintf(&session_name_date, "%s-%s", base_session_name, datetime);
                if (printed_bytes < 0) {
                        PERROR("Asprintf session name");
@@ -1470,6 +1478,9 @@ int cmd_create(int argc, const char **argv)
                        DBG("Session live timer interval set to %d", opt_live_timer);
                        break;
                }
+               case OPT_DEFAULT_NAME:
+                       opt_default_name = true;
+                       break;
                default:
                        ret = CMD_UNDEFINED;
                        goto end;
This page took 0.027867 seconds and 5 git commands to generate.