From aedbab3f0f0cf6369774aacbce515930e65dcaf4 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 14 May 2020 15:59:53 +0800 Subject: [PATCH] common: cli: allow fall back to simple cli The simple CLI mode only support run_command() which can't support powerful command line syntax like if...then...else...fi conditionals or `&&' and '||'. The run_command_list() falls back to run_command(). Signed-off-by: Joseph Chen Change-Id: I136cba71e02fd1f57c9a395b37679d9a885ba4a0 --- common/Makefile | 2 +- common/cli.c | 7 +++++-- common/command.c | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/Makefile b/common/Makefile index a2c78cc509..e09461f58a 100644 --- a/common/Makefile +++ b/common/Makefile @@ -59,7 +59,7 @@ obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_UPDATE_TFTP) += update.o obj-$(CONFIG_DFU_TFTP) += update.o obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o -obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o +obj-y += cli_readline.o cli_simple.o endif # !CONFIG_SPL_BUILD diff --git a/common/cli.c b/common/cli.c index a96db7e3e1..d4074a7ef8 100644 --- a/common/cli.c +++ b/common/cli.c @@ -18,7 +18,11 @@ DECLARE_GLOBAL_DATA_PTR; -#ifdef CONFIG_CMDLINE +__weak int board_run_command(const char *cmdline) +{ + return cli_simple_run_command_list((char *)cmdline, 0); +} + /* * Run a command using the selected parser. * @@ -69,7 +73,6 @@ int run_command_repeatable(const char *cmd, int flag) return 0; #endif } -#endif /* CONFIG_CMDLINE */ int run_command_list(const char *cmd, int len, int flag) { diff --git a/common/command.c b/common/command.c index e5d9b9cf95..7171557265 100644 --- a/common/command.c +++ b/common/command.c @@ -85,7 +85,6 @@ int _do_help(cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t *cmdtp, int flag, /* find command table entry for a command */ cmd_tbl_t *find_cmd_tbl(const char *cmd, cmd_tbl_t *table, int table_len) { -#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp; cmd_tbl_t *cmdtp_temp = table; /* Init value */ const char *p; @@ -112,7 +111,6 @@ cmd_tbl_t *find_cmd_tbl(const char *cmd, cmd_tbl_t *table, int table_len) if (n_found == 1) { /* exactly one match */ return cmdtp_temp; } -#endif /* CONFIG_CMDLINE */ return NULL; /* not found or ambiguous command */ }