Fix: `babeltrace2 convert`: don't consider the `--plugin-path` opt.
[babeltrace.git] / src / cli / babeltrace2-cfg-cli-args.c
index 73d67d7785d50f42ff89788d28dd4a10a5a07dd5..5180dadc6108b4021b8d3baaa57c0d36f464a712 100644 (file)
@@ -147,17 +147,14 @@ void plugin_comp_cls_names(const char *arg, char **name, char **plugin,
                        *name = NULL;
                        g_string_free(gs_name, TRUE);
                } else {
-                       *name = gs_name->str;
-                       g_string_free(gs_name, FALSE);
+                       *name = g_string_free(gs_name, FALSE);
                }
        } else {
                g_string_free(gs_name, TRUE);
        }
 
-       *plugin = gs_plugin->str;
-       *comp_cls = gs_comp_cls->str;
-       g_string_free(gs_plugin, FALSE);
-       g_string_free(gs_comp_cls, FALSE);
+       *plugin = g_string_free(gs_plugin, FALSE);
+       *comp_cls = g_string_free(gs_comp_cls, FALSE);
        gs_name = NULL;
        gs_plugin = NULL;
        gs_comp_cls = NULL;
@@ -191,16 +188,96 @@ end:
        return;
 }
 
+static
+void print_and_indent(const char *str)
+{
+       const char *ch = &str[0];
+
+       for (; *ch != '\0'; ch++) {
+               if (*ch == '\n') {
+                       if (ch[1] != '\0') {
+                               printf("\n  ");
+                       }
+               } else {
+                       printf("%c", *ch);
+               }
+       }
+
+       printf("\n");
+}
+
 /*
  * Prints the Babeltrace version.
  */
 static
 void print_version(void)
 {
-       if (BT_VERSION_GIT[0] == '\0') {
-               puts("Babeltrace " VERSION);
-       } else {
-               puts("Babeltrace " VERSION  " - " BT_VERSION_GIT);
+       bool has_extra_name = strlen(BT_VERSION_EXTRA_NAME) > 0;
+       bool has_extra_description = strlen(BT_VERSION_EXTRA_DESCRIPTION) > 0;
+       bool has_extra_patch_names = strlen(BT_VERSION_EXTRA_PATCHES) > 0;
+       bool has_extra = has_extra_name || has_extra_description ||
+               has_extra_patch_names;
+
+       printf("%sBabeltrace %s%s",
+               bt_common_color_bold(),
+               VERSION,
+               bt_common_color_reset());
+
+       if (strlen(BT_VERSION_NAME) > 0) {
+               printf(" \"%s%s%s%s\"",
+                       bt_common_color_fg_bright_blue(),
+                       bt_common_color_bold(),
+                       BT_VERSION_NAME,
+                       bt_common_color_reset());
+       }
+
+       if (strlen(BT_VERSION_GIT) > 0) {
+               printf(" [%s%s%s]",
+                       bt_common_color_fg_yellow(),
+                       BT_VERSION_GIT,
+                       bt_common_color_reset());
+       }
+
+       printf("\n");
+
+       if (strlen(BT_VERSION_DESCRIPTION) > 0) {
+               unsigned int columns;
+               GString *descr;
+
+               if (bt_common_get_term_size(&columns, NULL) < 0) {
+                       /* Width not found: default to 80 */
+                       columns = 80;
+               }
+
+               descr = bt_common_fold(BT_VERSION_DESCRIPTION, columns, 0);
+               BT_ASSERT(descr);
+               printf("\n%s\n", descr->str);
+               g_string_free(descr, TRUE);
+       }
+
+       if (has_extra) {
+               printf("\n");
+
+               if (has_extra_name) {
+                       printf("%sExtra name%s: %s\n",
+                               bt_common_color_fg_cyan(),
+                               bt_common_color_reset(),
+                               BT_VERSION_EXTRA_NAME);
+               }
+
+               if (has_extra_description) {
+                       printf("%sExtra description%s:\n  ",
+                               bt_common_color_fg_cyan(),
+                               bt_common_color_reset());
+                       print_and_indent(BT_VERSION_EXTRA_DESCRIPTION);
+               }
+
+               if (has_extra_patch_names) {
+                       printf("%sExtra patch names%s:\n  ",
+                               bt_common_color_fg_cyan(),
+                               bt_common_color_reset());
+                       print_and_indent(BT_VERSION_EXTRA_PATCHES);
+               }
        }
 }
 
@@ -2199,7 +2276,6 @@ const struct argpar_opt_descr convert_options[] = {
        { OPT_OUTPUT, 'w', "output", true },
        { OPT_OUTPUT_FORMAT, 'o', "output-format", true },
        { OPT_PARAMS, 'p', "params", true },
-       { OPT_PLUGIN_PATH, '\0', "plugin-path", true },
        { OPT_RETRY_DURATION, '\0', "retry-duration", true },
        { OPT_RUN_ARGS, '\0', "run-args", false },
        { OPT_RUN_ARGS_0, '\0', "run-args-0", false },
@@ -2862,10 +2938,8 @@ int split_timerange(const char *arg, char **begin, char **end)
 
        BT_ASSERT(begin);
        BT_ASSERT(end);
-       *begin = g_begin->str;
-       *end = g_end->str;
-       g_string_free(g_begin, FALSE);
-       g_string_free(g_end, FALSE);
+       *begin = g_string_free(g_begin, FALSE);
+       *end = g_string_free(g_end, FALSE);
        g_begin = NULL;
        g_end = NULL;
        goto end;
@@ -3563,7 +3637,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                switch (argpar_item_opt->descr->id) {
                case OPT_BEGIN:
                        if (trimmer_has_begin) {
-                               printf("At --begin option: --begin or --timerange option already specified\n    %s\n",
+                               BT_CLI_LOGE_APPEND_CAUSE("At --begin option: --begin or --timerange option already specified\n    %s\n",
                                        arg);
                                goto error;
                        }
@@ -3578,7 +3652,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                        break;
                case OPT_END:
                        if (trimmer_has_end) {
-                               printf("At --end option: --end or --timerange option already specified\n    %s\n",
+                               BT_CLI_LOGE_APPEND_CAUSE("At --end option: --end or --timerange option already specified\n    %s\n",
                                        arg);
                                goto error;
                        }
@@ -3597,7 +3671,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                        char *end;
 
                        if (trimmer_has_begin || trimmer_has_end) {
-                               printf("At --timerange option: --begin, --end, or --timerange option already specified\n    %s\n",
+                               BT_CLI_LOGE_APPEND_CAUSE("At --timerange option: --begin, --end, or --timerange option already specified\n    %s\n",
                                        arg);
                                goto error;
                        }
This page took 0.026195 seconds and 4 git commands to generate.