return result;
}
-#include "play.command_list.h"
-
-typedef int play_command_handler_t(struct play_task *, int, char**);
-
-/* defines one command of para_play */
-struct pp_command {
- const char *name;
- play_command_handler_t *handler;
- const char *description;
- const char *usage;
- const char *help;
-};
-
-static struct pp_command pp_cmds[] = {DEFINE_PLAY_CMD_ARRAY};
-#define FOR_EACH_COMMAND(c) for (c = 0; pp_cmds[c].name; c++)
-
static struct i9e_completer pp_completers[];
I9E_DUMMY_COMPLETER(jmp);
lls_command_name(cmd), lls_purpose(cmd));
btr_add_output(buf, sz, pt->btrn);
}
- FOR_EACH_COMMAND(i) {
- sz = xasprintf(&buf, "%s\t%s\n", pp_cmds[i].name,
- pp_cmds[i].description);
- btr_add_output(buf, sz, pt->btrn);
- }
return 0;
}
FOR_EACH_MAPPED_KEY(i) {
static int run_command(char *line, struct play_task *pt)
{
- int i, ret, argc;
+ int ret, argc;
char **argv = NULL;
char *errctx = NULL;
const struct play_command_info *pci;
if (ret == 0)
goto out;
argc = ret;
-
ret = lls(lls_lookup_subcmd(argv[0], play_cmd_suite, &errctx));
- if (ret >= 0) {
- cmd = lls_cmd(ret, play_cmd_suite);
- ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx));
- if (ret < 0)
- goto out;
- pci = lls_user_data(cmd);
- ret = pci->handler(pt, lpr);
- lls_free_parse_result(lpr, cmd);
- } else {
- FOR_EACH_COMMAND(i) {
- if (strcmp(pp_cmds[i].name, argv[0]))
- continue;
- free(errctx);
- errctx = NULL;
- ret = pp_cmds[i].handler(pt, argc, argv);
- break;
- }
- }
+ if (ret < 0)
+ goto out;
+ cmd = lls_cmd(ret, play_cmd_suite);
+ ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx));
+ if (ret < 0)
+ goto out;
+ pci = lls_user_data(cmd);
+ ret = pci->handler(pt, lpr);
+ lls_free_parse_result(lpr, cmd);
out:
if (errctx)
PARA_ERROR_LOG("%s\n", errctx);