- for (i = 0; i < argpar_parse_ret.items->len; i++) {
- struct bt_argpar_item *argpar_item =
- g_ptr_array_index(argpar_parse_ret.items, i);
-
- if (argpar_item->type == BT_ARGPAR_ITEM_TYPE_OPT) {
- struct bt_argpar_item_opt *argpar_item_opt;
- const char *arg;
- argpar_item_opt = (struct bt_argpar_item_opt *) argpar_item;
- arg = argpar_item_opt->arg;
-
- switch (argpar_item_opt->descr->id) {
- case OPT_PLUGIN_PATH:
- if (bt_config_append_plugin_paths_check_setuid_setgid(
- cfg->plugin_paths, arg)) {
- goto error;
- }
- break;
- case OPT_OMIT_SYSTEM_PLUGIN_PATH:
- cfg->omit_system_plugin_path = true;
- break;
- case OPT_OMIT_HOME_PLUGIN_PATH:
- cfg->omit_home_plugin_path = true;
- break;
- default:
- BT_CLI_LOGE_APPEND_CAUSE("Unknown command-line option specified (option code %d).",
- argpar_item_opt->descr->id);
- goto error;
- }
- } else {
- struct bt_argpar_item_non_opt *argpar_item_non_opt
- = (struct bt_argpar_item_non_opt *) argpar_item;
-
- if (non_opt) {
- BT_CLI_LOGE_APPEND_CAUSE("Extraneous command-line argument specified to `help` command: `%s`.",
- argpar_item_non_opt->arg);
- goto error;
- }
-
- non_opt = argpar_item_non_opt->arg;
- }
+ if (argpar_parse_ret.items->len == 0) {
+ BT_CLI_LOGE_APPEND_CAUSE(
+ "Missing plugin name or component class descriptor.");
+ goto error;
+ } else if (argpar_parse_ret.items->len > 1) {
+ /*
+ * At this point we know there are least two non-option
+ * arguments because we don't reach here with `--help`,
+ * the only option.
+ */
+ non_opt = argpar_parse_ret.items->pdata[1];
+ BT_CLI_LOGE_APPEND_CAUSE(
+ "Extraneous command-line argument specified to `help` command: `%s`.",
+ non_opt->arg);
+ goto error;