From f99c53dce127b5931ce00be3be9530401c93eea0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 15 Jun 2016 16:59:51 -0400 Subject: [PATCH] Implement --default-output option of create command MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/create.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 62607a038..75edd2bee 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -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; -- 2.34.1