From 5451ff2848b31a4dc7168f514ee6c7a081d84723 Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Mon, 26 Nov 2018 15:56:24 +0100 Subject: [PATCH] shell: remove "options" concept Removing help "options" from shell API. Currently SHELL_OPT macro is not used by users. What is more commit: a89690d10f1 ignores possible options created in command handler by the user. As a result they are not printed in help message. Second, currntly implemented "options" in command handlers options are implemented without SHELL_OPT macro. And last but not least this change will allow to implement help handler in a way that user will not need to think about calling functions printing help in a command handler. Signed-off-by: Jakub Rzeszutko --- doc/subsystems/shell/shell.rst | 2 +- drivers/flash/flash_shell.c | 4 +- drivers/pci/pci_shell.c | 2 +- include/shell/shell.h | 37 ++-------- samples/drivers/flash_shell/src/main.c | 22 +++--- samples/mpu/mpu_test/src/main.c | 12 ++-- samples/net/promiscuous_mode/src/main.c | 2 +- samples/net/rpl_border_router/src/shell.c | 4 +- samples/net/zperf/src/zperf_shell.c | 24 +++---- .../shell/shell_module/src/dynamic_cmd.c | 10 +-- samples/subsys/shell/shell_module/src/main.c | 4 +- subsys/bluetooth/host/mesh/shell.c | 6 +- subsys/bluetooth/shell/bredr.c | 10 +-- subsys/bluetooth/shell/bt.c | 18 ++--- subsys/bluetooth/shell/gatt.c | 4 +- subsys/bluetooth/shell/l2cap.c | 4 +- subsys/bluetooth/shell/rfcomm.c | 2 +- subsys/bluetooth/shell/ticker.c | 2 +- subsys/fs/shell.c | 14 ++-- subsys/logging/log_cmds.c | 8 +-- subsys/net/ip/net_shell.c | 66 ++++++++--------- subsys/net/l2/bluetooth/bluetooth_shell.c | 8 +-- subsys/net/l2/ieee802154/ieee802154_shell.c | 28 ++++---- subsys/net/l2/wifi/wifi_shell.c | 10 +-- subsys/net/lib/openthread/platform/shell.c | 2 +- subsys/shell/shell.c | 71 ++----------------- subsys/shell/shell_cmds.c | 36 +++++----- tests/bluetooth/shell/src/main.c | 8 +-- tests/shell/src/main.c | 2 +- 29 files changed, 168 insertions(+), 254 deletions(-) diff --git a/doc/subsystems/shell/shell.rst b/doc/subsystems/shell/shell.rst index d3ce5e63001..8c0289ea9e0 100644 --- a/doc/subsystems/shell/shell.rst +++ b/doc/subsystems/shell/shell.rst @@ -289,7 +289,7 @@ checks for valid arguments count. ARG_UNUSED(argv); if (shell_help_requested(shell) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); } else { shell_fprintf(shell, SHELL_NORMAL, "Command called with no -h or --help option." diff --git a/drivers/flash/flash_shell.c b/drivers/flash/flash_shell.c index 2eda678f025..d0270e8965b 100644 --- a/drivers/flash/flash_shell.c +++ b/drivers/flash/flash_shell.c @@ -231,12 +231,12 @@ static int cmd_flash(const struct shell *shell, size_t argc, char **argv) int err; if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } - err = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + err = shell_cmd_precheck(shell, argc == 2); if (err) { return err; } diff --git a/drivers/pci/pci_shell.c b/drivers/pci/pci_shell.c index 3349b67d019..b1ae3ce79dd 100644 --- a/drivers/pci/pci_shell.c +++ b/drivers/pci/pci_shell.c @@ -45,7 +45,7 @@ static int cmd_lspci(const struct shell *shell, size_t argc, char **argv) }; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 1; } diff --git a/include/shell/shell.h b/include/shell/shell.h index 57f6d5f3e8a..b886b5df643 100644 --- a/include/shell/shell.h +++ b/include/shell/shell.h @@ -615,28 +615,6 @@ void shell_fprintf(const struct shell *shell, enum shell_vt100_color color, */ void shell_process(const struct shell *shell); -/** - * @brief Option descriptor. - */ -struct shell_getopt_option { - const char *optname; /*!< Option long name.*/ - const char *optname_short; /*!< Option short name.*/ - const char *optname_help; /*!< Option help string.*/ -}; - -/** - * @brief Option structure initializer. - * - * @param[in] _optname Option name long. - * @param[in] _shortname Option name short. - * @param[in] _help Option help string. - */ -#define SHELL_OPT(_optname, _shortname, _help) { \ - .optname = _optname, \ - .optname_short = _shortname, \ - .optname_help = _help, \ - } - /** * @brief Informs that a command has been called with -h or --help option. * @@ -652,15 +630,12 @@ static inline bool shell_help_requested(const struct shell *shell) /** * @brief Prints the current command help. * - * Function will print a help string with: the currently entered command, its - * options,and subcommands (if they exist). + * Function will print a help string with the currently entered command and + * its subcommands (if exist). * * @param[in] shell Pointer to the shell instance. - * @param[in] opt Pointer to the optional option array. - * @param[in] opt_len Option array size. */ -void shell_help_print(const struct shell *shell, - const struct shell_getopt_option *opt, size_t opt_len); +void shell_help_print(const struct shell *shell); /** * @brief Change displayed shell prompt. @@ -680,17 +655,13 @@ int shell_prompt_change(const struct shell *shell, char *prompt); * * @param[in] shell Pointer to the shell instance. * @param[in] arg_cnt_ok Flag indicating valid number of arguments. - * @param[in] opt Pointer to the optional option array. - * @param[in] opt_len Option array size. * * @return 0 if check passed * @return 1 if help was requested * @return -EINVAL if wrong argument count */ int shell_cmd_precheck(const struct shell *shell, - bool arg_cnt_ok, - const struct shell_getopt_option *opt, - size_t opt_len); + bool arg_cnt_ok); /** * @internal @brief This function shall not be used directly, it is required by diff --git a/samples/drivers/flash_shell/src/main.c b/samples/drivers/flash_shell/src/main.c index d66eda98447..0f261bdb1c2 100644 --- a/samples/drivers/flash_shell/src/main.c +++ b/samples/drivers/flash_shell/src/main.c @@ -233,7 +233,7 @@ static int cmd_flash(const struct shell *shell, size_t argc, char **argv) ARG_UNUSED(argc); ARG_UNUSED(argv); - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -243,7 +243,7 @@ static int cmd_write_block_size(const struct shell *shell, size_t argc, { ARG_UNUSED(argv); - int err = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int err = shell_cmd_precheck(shell, argc == 1); if (err) { return err; @@ -261,7 +261,7 @@ static int cmd_write_block_size(const struct shell *shell, size_t argc, static int cmd_read(const struct shell *shell, size_t argc, char **argv) { - int err = shell_cmd_precheck(shell, (argc == 3), NULL, 0); + int err = shell_cmd_precheck(shell, argc == 3); unsigned long int offset, len; if (err) { @@ -287,7 +287,7 @@ exit: static int cmd_erase(const struct shell *shell, size_t argc, char **argv) { - int err = shell_cmd_precheck(shell, (argc == 3), NULL, 0); + int err = shell_cmd_precheck(shell, argc == 3); unsigned long int offset, size; if (err) { @@ -312,7 +312,7 @@ exit: static int cmd_write(const struct shell *shell, size_t argc, char **argv) { - int err = shell_cmd_precheck(shell, (argc > 2), NULL, 0); + int err = shell_cmd_precheck(shell, argc > 2); unsigned long int i, offset; u8_t buf[ARGC_MAX]; @@ -366,7 +366,7 @@ static int cmd_page_count(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - int err = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int err = shell_cmd_precheck(shell, argc == 1); size_t page_count; if (err) { @@ -409,7 +409,7 @@ static bool page_layout_cb(const struct flash_pages_info *info, void *datav) static int cmd_page_layout(const struct shell *shell, size_t argc, char **argv) { - int err = shell_cmd_precheck(shell, (argc <= 3), NULL, 0); + int err = shell_cmd_precheck(shell, argc <= 3); unsigned long int start_page, end_page; struct page_layout_data data; @@ -464,7 +464,7 @@ static int cmd_page_read(const struct shell *shell, size_t argc, char **argv) int ret; - ret = shell_cmd_precheck(shell, (argc == 3) || (argc == 4), NULL, 0); + ret = shell_cmd_precheck(shell, argc == 3 || argc == 4); if (ret) { return ret; } @@ -512,7 +512,7 @@ static int cmd_page_erase(const struct shell *shell, size_t argc, char **argv) return ret; } - ret = shell_cmd_precheck(shell, (argc == 2) || (argc == 3), NULL, 0); + ret = shell_cmd_precheck(shell, argc == 2 || argc == 3); if (ret) { return ret; } @@ -563,7 +563,7 @@ static int cmd_page_write(const struct shell *shell, size_t argc, char **argv) return ret; } - ret = shell_cmd_precheck(shell, (argc > 2), NULL, 0); + ret = shell_cmd_precheck(shell, argc > 2); if (ret) { return ret; } @@ -603,7 +603,7 @@ static int cmd_set_dev(const struct shell *shell, size_t argc, char **argv) const char *name; int ret; - ret = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + ret = shell_cmd_precheck(shell, argc == 2); if (ret) { return ret; } diff --git a/samples/mpu/mpu_test/src/main.c b/samples/mpu/mpu_test/src/main.c index 0787756298f..0727d812ee0 100644 --- a/samples/mpu/mpu_test/src/main.c +++ b/samples/mpu/mpu_test/src/main.c @@ -35,7 +35,7 @@ static int cmd_read(const struct shell *shell, size_t argc, char *argv[]) u32_t *p_mem = (u32_t *) RESERVED_MEM_MAP; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -56,7 +56,7 @@ static int cmd_write_mcux(const struct shell *shell, size_t argc, char *argv[]) u32_t offset; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -91,7 +91,7 @@ static int cmd_write_stm32(const struct shell *shell, size_t argc, char *argv[]) struct device *flash_dev; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -124,7 +124,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char *argv[]) u32_t *p_mem = (u32_t *) (FLASH_MEM + 0x4000); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -145,7 +145,7 @@ static int cmd_run(const struct shell *shell, size_t argc, char *argv[]) void (*func_ptr)(void) = (void (*)(void)) RAM_MEM; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -167,7 +167,7 @@ static int cmd_mtest(const struct shell *shell, size_t argc, char *argv[]) return -EINVAL; } - err = shell_cmd_precheck(shell, (argc >= 2) && (argc <= 3), NULL, 0); + err = shell_cmd_precheck(shell, (argc >= 2) && (argc <= 3)); if (err) { return err; } diff --git a/samples/net/promiscuous_mode/src/main.c b/samples/net/promiscuous_mode/src/main.c index 89e74f65d5d..79f8461482c 100644 --- a/samples/net/promiscuous_mode/src/main.c +++ b/samples/net/promiscuous_mode/src/main.c @@ -147,7 +147,7 @@ static int set_promisc_mode(const struct shell *shell, int idx, ret; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/samples/net/rpl_border_router/src/shell.c b/samples/net/rpl_border_router/src/shell.c index e613642e110..9b283b33de0 100644 --- a/samples/net/rpl_border_router/src/shell.c +++ b/samples/net/rpl_border_router/src/shell.c @@ -25,7 +25,7 @@ static int cmd_br_repair(const struct shell *shell, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -44,7 +44,7 @@ static int cmd_coap_send(const struct shell *shell, int r; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/samples/net/zperf/src/zperf_shell.c b/samples/net/zperf/src/zperf_shell.c index f1c1b2f3eef..78378a95180 100644 --- a/samples/net/zperf/src/zperf_shell.c +++ b/samples/net/zperf/src/zperf_shell.c @@ -226,7 +226,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_NET_IPV6) && !IS_ENABLED(CONFIG_NET_IPV4)) { if (argc != 3 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -244,7 +244,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_NET_IPV4) && !IS_ENABLED(CONFIG_NET_IPV6)) { if (argc != 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -262,7 +262,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_NET_IPV6) && IS_ENABLED(CONFIG_NET_IPV4)) { if (net_addr_pton(AF_INET6, argv[start + 1], &ipv6) < 0) { if (argc != 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -278,7 +278,7 @@ static int cmd_setip(const struct shell *shell, size_t argc, char *argv[]) net_sprint_ipv4_addr(&ipv4)); } else { if (argc != 3 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -308,7 +308,7 @@ static int cmd_udp_download(const struct shell *shell, size_t argc, do_init(shell); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -693,12 +693,12 @@ static int shell_cmd_upload(const struct shell *shell, size_t argc, if (is_udp) { if (IS_ENABLED(CONFIG_NET_UDP)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } } else { if (IS_ENABLED(CONFIG_NET_TCP)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } } @@ -833,12 +833,12 @@ static int shell_cmd_upload2(const struct shell *shell, size_t argc, if (is_udp) { if (IS_ENABLED(CONFIG_NET_UDP)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } } else { if (IS_ENABLED(CONFIG_NET_TCP)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } } @@ -941,7 +941,7 @@ static int cmd_tcp(const struct shell *shell, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_NET_TCP)) { do_init(shell); - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -956,7 +956,7 @@ static int cmd_udp(const struct shell *shell, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_NET_UDP)) { do_init(shell); - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -984,7 +984,7 @@ static int cmd_tcp_download(const struct shell *shell, size_t argc, do_init(shell); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/samples/subsys/shell/shell_module/src/dynamic_cmd.c b/samples/subsys/shell/shell_module/src/dynamic_cmd.c index 57915f95cce..e61af2e857a 100644 --- a/samples/subsys/shell/shell_module/src/dynamic_cmd.c +++ b/samples/subsys/shell/shell_module/src/dynamic_cmd.c @@ -22,7 +22,7 @@ extern void qsort(void *a, size_t n, size_t es, cmp_t *cmp); static int cmd_dynamic(const struct shell *shell, size_t argc, char **argv) { if ((argc == 1) || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -50,7 +50,7 @@ static int cmd_dynamic_add(const struct shell *shell, u16_t cmd_len; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -103,7 +103,7 @@ static int cmd_dynamic_show(const struct shell *shell, size_t argc, char **argv) { if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -133,7 +133,7 @@ static int cmd_dynamic_execute(const struct shell *shell, size_t argc, char **argv) { if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -161,7 +161,7 @@ static int cmd_dynamic_remove(const struct shell *shell, size_t argc, char **argv) { if ((argc == 1) || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } diff --git a/samples/subsys/shell/shell_module/src/main.c b/samples/subsys/shell/shell_module/src/main.c index 0fdd451ead9..cf12565f1ab 100644 --- a/samples/subsys/shell/shell_module/src/main.c +++ b/samples/subsys/shell/shell_module/src/main.c @@ -31,7 +31,7 @@ static int cmd_log_test_start(const struct shell *shell, size_t argc, { ARG_UNUSED(argv); - int err = shell_cmd_precheck(shell, argc == 1, NULL, 0); + int err = shell_cmd_precheck(shell, argc == 1); if (err) { return err; @@ -62,7 +62,7 @@ static int cmd_log_test_stop(const struct shell *shell, size_t argc, ARG_UNUSED(argc); ARG_UNUSED(argv); - int err = shell_cmd_precheck(shell, argc == 1, NULL, 0); + int err = shell_cmd_precheck(shell, argc == 1); if (err) { return err; diff --git a/subsys/bluetooth/host/mesh/shell.c b/subsys/bluetooth/host/mesh/shell.c index 7f2433c6875..30f43d0674f 100644 --- a/subsys/bluetooth/host/mesh/shell.c +++ b/subsys/bluetooth/host/mesh/shell.c @@ -1576,7 +1576,7 @@ int cmd_timeout(const struct shell *shell, size_t argc, char *argv[]) s32_t timeout; int err; - err = shell_cmd_precheck(shell, (argc >= 1), NULL, 0); + err = shell_cmd_precheck(shell, (argc >= 1)); if (err) { return err; } @@ -1619,7 +1619,7 @@ static int cmd_fault_get(const struct shell *shell, size_t argc, char *argv[]) u16_t cid; int err; - err = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + err = shell_cmd_precheck(shell, (argc == 1)); if (err) { return err; } @@ -2042,7 +2042,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(mesh_cmds) { static int cmd_mesh(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/bluetooth/shell/bredr.c b/subsys/bluetooth/shell/bredr.c index 49c7952b156..3517382d758 100644 --- a/subsys/bluetooth/shell/bredr.c +++ b/subsys/bluetooth/shell/bredr.c @@ -200,7 +200,7 @@ static int cmd_discovery(const struct shell *shell, size_t argc, char *argv[]) shell_print(shell, "Discovery stopped"); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); } return 0; @@ -296,7 +296,7 @@ static int cmd_discoverable(const struct shell *shell, } else if (!strcmp(action, "off")) { err = bt_br_set_discoverable(false); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -324,7 +324,7 @@ static int cmd_connectable(const struct shell *shell, } else if (!strcmp(action, "off")) { err = bt_br_set_connectable(false); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -514,7 +514,7 @@ static int cmd_sdp_find_record(const struct shell *shell, } else if (!strcmp(action, "A2SRC")) { discov = discov_a2src; } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -551,7 +551,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(br_cmds) { static int cmd_br(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index a19118a2a93..93cf88148c8 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -613,7 +613,7 @@ static int cmd_scan(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(dup_filter, "nodups")) { dups = BT_HCI_LE_SCAN_FILTER_DUP_ENABLE; } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -627,7 +627,7 @@ static int cmd_scan(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(action, "passive")) { return cmd_passive_scan_on(shell, dups); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -702,7 +702,7 @@ static int cmd_advertise(const struct shell *shell, size_t argc, char *argv[]) return 0; fail: - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -746,7 +746,7 @@ static int cmd_disconnect(const struct shell *shell, size_t argc, char *argv[]) bt_addr_le_t addr; if (argc < 3) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -795,7 +795,7 @@ static int cmd_auto_conn(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(argv[3], "off")) { return bt_le_set_auto_conn(&addr, NULL); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -822,7 +822,7 @@ static int cmd_directed_adv(const struct shell *shell, } if (strcmp(argv[3], "low")) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -1014,7 +1014,7 @@ static int cmd_bondable(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(bondable, "off")) { bt_set_bondable(false); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -1208,7 +1208,7 @@ static int cmd_auth(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(argv[1], "none")) { bt_conn_auth_cb_register(NULL); } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } @@ -1389,7 +1389,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(bt_cmds) { static int cmd_bt(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/bluetooth/shell/gatt.c b/subsys/bluetooth/shell/gatt.c index 358316cf24a..1cb153cf2b0 100644 --- a/subsys/bluetooth/shell/gatt.c +++ b/subsys/bluetooth/shell/gatt.c @@ -740,7 +740,7 @@ static int cmd_metrics(const struct shell *shell, size_t argc, char *argv[]) err = bt_gatt_service_unregister(&met_svc); } else { shell_error(shell, "Incorrect value: %s", argv[1]); - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -796,7 +796,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(gatt_cmds) { static int cmd_gatt(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/bluetooth/shell/l2cap.c b/subsys/bluetooth/shell/l2cap.c index a6223e2ed81..4715ff3c364 100644 --- a/subsys/bluetooth/shell/l2cap.c +++ b/subsys/bluetooth/shell/l2cap.c @@ -354,7 +354,7 @@ static int cmd_metrics(const struct shell *shell, size_t argc, char *argv[]) } else if (!strcmp(action, "off")) { l2cap_ops.recv = l2cap_recv; } else { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } @@ -416,7 +416,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(l2cap_cmds) { static int cmd_l2cap(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/bluetooth/shell/rfcomm.c b/subsys/bluetooth/shell/rfcomm.c index a7cc7f5a632..a3f26c9e514 100644 --- a/subsys/bluetooth/shell/rfcomm.c +++ b/subsys/bluetooth/shell/rfcomm.c @@ -244,7 +244,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(rfcomm_cmds) { static int cmd_rfcomm(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/bluetooth/shell/ticker.c b/subsys/bluetooth/shell/ticker.c index 3178b349eb7..2b923b7dc90 100644 --- a/subsys/bluetooth/shell/ticker.c +++ b/subsys/bluetooth/shell/ticker.c @@ -135,7 +135,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(ticker_cmds) { static int cmd_ticker(const struct shell *shell, size_t argc, char **argv) { if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/subsys/fs/shell.c b/subsys/fs/shell.c index 13da8c61d82..28b9ee9524b 100644 --- a/subsys/fs/shell.c +++ b/subsys/fs/shell.c @@ -166,7 +166,7 @@ static int cmd_trunc(const struct shell *shell, size_t argc, char **argv) int length; int err; - err = shell_cmd_precheck(shell, (argc >= 2), NULL, 0); + err = shell_cmd_precheck(shell, (argc >= 2)); if (err) { return err; } @@ -212,7 +212,7 @@ static int cmd_mkdir(const struct shell *shell, size_t argc, char **argv) int err; char path[MAX_PATH_LEN]; - err = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + err = shell_cmd_precheck(shell, (argc == 2)); if (err) { return err; } @@ -234,7 +234,7 @@ static int cmd_rm(const struct shell *shell, size_t argc, char **argv) int err; char path[MAX_PATH_LEN]; - err = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + err = shell_cmd_precheck(shell, (argc == 2)); if (err) { return err; } @@ -260,7 +260,7 @@ static int cmd_read(const struct shell *shell, size_t argc, char **argv) off_t offset; int err; - err = shell_cmd_precheck(shell, (argc >= 2), NULL, 0); + err = shell_cmd_precheck(shell, (argc >= 2)); if (err) { return err; } @@ -356,7 +356,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char **argv) off_t offset = -1; int err; - err = shell_cmd_precheck(shell, (argc >= 3), NULL, 0); + err = shell_cmd_precheck(shell, (argc >= 3)); if (err) { return err; } @@ -439,7 +439,7 @@ static int cmd_mount_fat(const struct shell *shell, size_t argc, char **argv) char *mntpt; int res; - res = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + res = shell_cmd_precheck(shell, (argc == 2)); if (res) { return res; } @@ -473,7 +473,7 @@ static int cmd_mount_nffs(const struct shell *shell, size_t argc, char **argv) char *mntpt; int res; - res = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + res = shell_cmd_precheck(shell, (argc == 2)); if (res) { return res; } diff --git a/subsys/logging/log_cmds.c b/subsys/logging/log_cmds.c index fb8c2ad059c..ad3a575b1c2 100644 --- a/subsys/logging/log_cmds.c +++ b/subsys/logging/log_cmds.c @@ -214,7 +214,7 @@ static int log_enable(const struct shell *shell, char **argv) { int severity_level; - int err = shell_cmd_precheck(shell, (argc > 1), NULL, 0); + int err = shell_cmd_precheck(shell, (argc > 1)); if (err) { return err; @@ -254,7 +254,7 @@ static int log_disable(const struct shell *shell, size_t argc, char **argv) { - int err = shell_cmd_precheck(shell, (argc > 1), NULL, 0); + int err = shell_cmd_precheck(shell, (argc > 1)); if (err) { return err; @@ -361,7 +361,7 @@ static int cmd_log_backends_list(const struct shell *shell, size_t argc, char **argv) { int backend_count; - int err = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int err = shell_cmd_precheck(shell, (argc == 1)); if (err) { return err; @@ -442,7 +442,7 @@ SHELL_CREATE_STATIC_SUBCMD_SET(sub_log_stat) static int cmd_log(const struct shell *shell, size_t argc, char **argv) { if ((argc == 1) || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 0; } diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index d0c51c1dca4..3fa153c168b 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -1153,7 +1153,7 @@ static int cmd_net_allocs(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1381,7 +1381,7 @@ static int cmd_net_app(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1459,7 +1459,7 @@ static int cmd_net_arp(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argc); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1489,7 +1489,7 @@ static int cmd_net_arp_flush(const struct shell *shell, size_t argc, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1512,7 +1512,7 @@ static int cmd_net_conn(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1694,7 +1694,7 @@ static int cmd_net_dns_cancel(const struct shell *shell, size_t argc, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1732,7 +1732,7 @@ static int cmd_net_dns_query(const struct shell *shell, size_t argc, char *argv[]) { if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -1793,7 +1793,7 @@ static int cmd_net_dns(const struct shell *shell, size_t argc, char *argv[]) #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2339,7 +2339,7 @@ static int cmd_net_gptp_port(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2376,7 +2376,7 @@ static int cmd_net_gptp(const struct shell *shell, size_t argc, char *argv[]) #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2498,7 +2498,7 @@ static int cmd_net_http_monitor(const struct shell *shell, size_t argc, char *argv[]) { if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2525,7 +2525,7 @@ static int cmd_net_http(const struct shell *shell, size_t argc, char *argv[]) #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2581,7 +2581,7 @@ static int cmd_net_iface_up(const struct shell *shell, size_t argc, int idx, ret; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2619,7 +2619,7 @@ static int cmd_net_iface_down(const struct shell *shell, size_t argc, int idx, ret; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2722,7 +2722,7 @@ static int cmd_net_ipv6(const struct shell *shell, size_t argc, char *argv[]) struct net_shell_user_data user_data; #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2793,7 +2793,7 @@ static int cmd_net_iface(const struct shell *shell, size_t argc, char *argv[]) int idx; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2913,7 +2913,7 @@ static int cmd_net_mem(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -2977,7 +2977,7 @@ static int cmd_net_nbr_rm(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3083,7 +3083,7 @@ static int cmd_net_nbr(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3248,7 +3248,7 @@ static int cmd_net_ping(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argc); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3307,7 +3307,7 @@ static int cmd_net_route(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3391,7 +3391,7 @@ static int cmd_net_rpl(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3552,7 +3552,7 @@ static int cmd_net_stacks(const struct shell *shell, size_t argc, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3632,7 +3632,7 @@ static int cmd_net_stats_all(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3665,7 +3665,7 @@ static int cmd_net_stats_iface(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3704,7 +3704,7 @@ static int cmd_net_stats_iface(const struct shell *shell, size_t argc, static int cmd_net_stats(const struct shell *shell, size_t argc, char *argv[]) { if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3941,7 +3941,7 @@ static int cmd_net_tcp_connect(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -3989,7 +3989,7 @@ static int cmd_net_tcp_send(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -4044,7 +4044,7 @@ static int cmd_net_tcp_close(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -4076,7 +4076,7 @@ static int cmd_net_tcp(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -4153,7 +4153,7 @@ static int cmd_net_vlan(const struct shell *shell, size_t argc, char *argv[]) #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -4184,7 +4184,7 @@ static int cmd_net_vlan_add(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -4261,7 +4261,7 @@ static int cmd_net_vlan_del(const struct shell *shell, size_t argc, #endif if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/subsys/net/l2/bluetooth/bluetooth_shell.c b/subsys/net/l2/bluetooth/bluetooth_shell.c index d32a27dc7a4..bee2f9e8631 100644 --- a/subsys/net/l2/bluetooth/bluetooth_shell.c +++ b/subsys/net/l2/bluetooth/bluetooth_shell.c @@ -85,7 +85,7 @@ static int shell_cmd_connect(const struct shell *shell, struct net_if *iface = net_if_get_default(); if (argc < 3 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -113,7 +113,7 @@ static int shell_cmd_scan(const struct shell *shell, struct net_if *iface = net_if_get_default(); if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -134,7 +134,7 @@ static int shell_cmd_disconnect(const struct shell *shell, struct net_if *iface = net_if_get_default(); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -155,7 +155,7 @@ static int shell_cmd_advertise(const struct shell *shell, struct net_if *iface = net_if_get_default(); if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/subsys/net/l2/ieee802154/ieee802154_shell.c b/subsys/net/l2/ieee802154/ieee802154_shell.c index 542a13c004f..eae37846826 100644 --- a/subsys/net/l2/ieee802154/ieee802154_shell.c +++ b/subsys/net/l2/ieee802154/ieee802154_shell.c @@ -37,7 +37,7 @@ static int cmd_ieee802154_ack(const struct shell *shell, ARG_UNUSED(argc); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -78,7 +78,7 @@ static int cmd_ieee802154_associate(const struct shell *shell, char ext_addr[MAX_EXT_ADDR_STR_LEN]; if (argc < 3 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -124,7 +124,7 @@ static int cmd_ieee802154_disassociate(const struct shell *shell, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -218,7 +218,7 @@ static int cmd_ieee802154_scan(const struct shell *shell, int ret; if (argc < 3 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -289,7 +289,7 @@ static int cmd_ieee802154_set_chan(const struct shell *shell, u16_t channel; if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -325,7 +325,7 @@ static int cmd_ieee802154_get_chan(const struct shell *shell, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -358,7 +358,7 @@ static int cmd_ieee802154_set_pan_id(const struct shell *shell, ARG_UNUSED(argc); if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -394,7 +394,7 @@ static int cmd_ieee802154_get_pan_id(const struct shell *shell, ARG_UNUSED(argv); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -425,7 +425,7 @@ static int cmd_ieee802154_set_ext_addr(const struct shell *shell, u8_t addr[IEEE802154_EXT_ADDR_LENGTH]; if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -464,7 +464,7 @@ static int cmd_ieee802154_get_ext_addr(const struct shell *shell, u8_t addr[IEEE802154_EXT_ADDR_LENGTH]; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -505,7 +505,7 @@ static int cmd_ieee802154_set_short_addr(const struct shell *shell, u16_t short_addr; if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -538,7 +538,7 @@ static int cmd_ieee802154_get_short_addr(const struct shell *shell, u16_t short_addr; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -569,7 +569,7 @@ static int cmd_ieee802154_set_tx_power(const struct shell *shell, s16_t tx_power; if (argc < 2 || shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -602,7 +602,7 @@ static int cmd_ieee802154_get_tx_power(const struct shell *shell, s16_t tx_power; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 22c25625d6c..e97a48d3c50 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -152,13 +152,13 @@ static int cmd_wifi_connect(const struct shell *shell, size_t argc, int idx = 3; if (shell_help_requested(shell) || argc < 3) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } cnx_params.ssid_length = strtol(argv[2], &endptr, 10); if (*endptr != '\0' || cnx_params.ssid_length <= 2) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -167,7 +167,7 @@ static int cmd_wifi_connect(const struct shell *shell, size_t argc, if ((idx < argc) && (strlen(argv[idx]) <= 2)) { cnx_params.channel = strtol(argv[idx], &endptr, 10); if (*endptr != '\0') { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -213,7 +213,7 @@ static int cmd_wifi_disconnect(const struct shell *shell, size_t argc, int status; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -246,7 +246,7 @@ static int cmd_wifi_scan(const struct shell *shell, size_t argc, char *argv[]) struct net_if *iface = net_if_get_default(); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/subsys/net/lib/openthread/platform/shell.c b/subsys/net/lib/openthread/platform/shell.c index b75a38281a1..ac6cee0c00a 100644 --- a/subsys/net/lib/openthread/platform/shell.c +++ b/subsys/net/lib/openthread/platform/shell.c @@ -36,7 +36,7 @@ static int ot_cmd(const struct shell *shell, size_t argc, char *argv[]) int i; if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 64ef9171a4a..b3449b8805a 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -980,7 +980,7 @@ static int exec_cmd(const struct shell *shell, size_t argc, char **argv) if (shell->ctx->active_cmd.handler == NULL) { if (shell->ctx->active_cmd.help) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); } else { shell_fprintf(shell, SHELL_ERROR, SHELL_MSG_SPECIFY_SUBCOMMAND); @@ -1001,13 +1001,11 @@ static int exec_cmd(const struct shell *shell, size_t argc, char **argv) ((argc >= args->mandatory) && (argc <= args->mandatory + - args->optional)), - NULL, 0); + args->optional))); } else { /* Perform exact match if there are no optional args */ ret_val = shell_cmd_precheck(shell, - (args->mandatory == argc), - NULL, 0); + (args->mandatory == argc)); } } @@ -1661,57 +1659,6 @@ static void help_item_print(const struct shell *shell, const char *item_name, formatted_text_print(shell, item_help, offset, false); } -static void help_options_print(const struct shell *shell, - const struct shell_getopt_option *opt, - size_t opt_cnt) -{ - static const char opt_sep[] = ", "; /* options separator */ - static const char help_opt[] = "-h, --help"; - u16_t longest_name = shell_strlen(help_opt); - - shell_fprintf(shell, SHELL_NORMAL, "Options:\r\n"); - - if ((opt == NULL) || (opt_cnt == 0)) { - help_item_print(shell, help_opt, longest_name, - "Show command help."); - return; - } - - /* Looking for the longest option string. */ - for (size_t i = 0; i < opt_cnt; ++i) { - u16_t len = shell_strlen(opt[i].optname_short) + - shell_strlen(opt[i].optname) + - shell_strlen(opt_sep); - - longest_name = len > longest_name ? len : longest_name; - } - - /* help option is printed first */ - help_item_print(shell, help_opt, longest_name, "Show command help."); - - /* prepare a buffer to compose a string: - * option name short - option separator - option name - */ - memset(shell->ctx->temp_buff, 0, longest_name + 1); - - /* Formating and printing all available options (except -h, --help). */ - for (size_t i = 0; i < opt_cnt; ++i) { - if (opt[i].optname_short) { - strcpy(shell->ctx->temp_buff, opt[i].optname_short); - } - if (opt[i].optname) { - if (*shell->ctx->temp_buff) { - strcat(shell->ctx->temp_buff, opt_sep); - strcat(shell->ctx->temp_buff, opt[i].optname); - } else { - strcpy(shell->ctx->temp_buff, opt[i].optname); - } - } - help_item_print(shell, shell->ctx->temp_buff, longest_name, - opt[i].optname_help); - } -} - /* Function is printing command help, its subcommands name and subcommands * help string. */ @@ -1763,8 +1710,7 @@ static void help_subcmd_print(const struct shell *shell) } } -void shell_help_print(const struct shell *shell, - const struct shell_getopt_option *opt, size_t opt_len) +void shell_help_print(const struct shell *shell) { __ASSERT_NO_MSG(shell); @@ -1773,7 +1719,6 @@ void shell_help_print(const struct shell *shell, } help_cmd_print(shell); - help_options_print(shell, opt, opt_len); help_subcmd_print(shell); } @@ -1793,12 +1738,10 @@ int shell_prompt_change(const struct shell *shell, char *prompt) } int shell_cmd_precheck(const struct shell *shell, - bool arg_cnt_ok, - const struct shell_getopt_option *opt, - size_t opt_len) + bool arg_cnt_ok) { if (shell_help_requested(shell)) { - shell_help_print(shell, opt, opt_len); + shell_help_print(shell); return 1; /* help printed */ } @@ -1808,7 +1751,7 @@ int shell_cmd_precheck(const struct shell *shell, shell->ctx->active_cmd.syntax); if (IS_ENABLED(CONFIG_SHELL_HELP_ON_WRONG_ARGUMENT_COUNT)) { - shell_help_print(shell, opt, opt_len); + shell_help_print(shell); } return -EINVAL; diff --git a/subsys/shell/shell_cmds.c b/subsys/shell/shell_cmds.c index 8eceeb89d77..e77558dea26 100644 --- a/subsys/shell/shell_cmds.c +++ b/subsys/shell/shell_cmds.c @@ -184,7 +184,7 @@ static int cmd_clear(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret) { return ret; @@ -198,7 +198,7 @@ static int cmd_clear(const struct shell *shell, size_t argc, char **argv) static int cmd_shell(const struct shell *shell, size_t argc, char **argv) { - int ret = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 2)); if (ret) { return ret; @@ -215,7 +215,7 @@ static int cmd_bacskpace_mode_backspace(const struct shell *shell, size_t argc, { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->ctx->internal.flags.mode_delete = 0; @@ -229,7 +229,7 @@ static int cmd_bacskpace_mode_delete(const struct shell *shell, size_t argc, { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->ctx->internal.flags.mode_delete = 1; @@ -241,7 +241,7 @@ static int cmd_bacskpace_mode_delete(const struct shell *shell, size_t argc, static int cmd_bacskpace_mode(const struct shell *shell, size_t argc, char **argv) { - int ret = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 2)); if (ret) { return ret; @@ -257,7 +257,7 @@ static int cmd_colors_off(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->ctx->internal.flags.use_colors = 0; @@ -270,7 +270,7 @@ static int cmd_colors_on(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->ctx->internal.flags.use_colors = 1; @@ -281,7 +281,7 @@ static int cmd_colors_on(const struct shell *shell, size_t argc, char **argv) static int cmd_colors(const struct shell *shell, size_t argc, char **argv) { - int ret = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 2)); if (ret) { return ret; @@ -297,7 +297,7 @@ static int cmd_echo_off(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->ctx->internal.flags.echo = 0; @@ -310,7 +310,7 @@ static int cmd_echo_on(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->ctx->internal.flags.echo = 1; @@ -321,7 +321,7 @@ static int cmd_echo_on(const struct shell *shell, size_t argc, char **argv) static int cmd_echo(const struct shell *shell, size_t argc, char **argv) { - int ret = shell_cmd_precheck(shell, (argc <= 2), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc <= 2)); if (ret) { return ret; @@ -367,7 +367,7 @@ static int cmd_history(const struct shell *shell, size_t argc, char **argv) return -ENOEXEC; } - ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + ret = shell_cmd_precheck(shell, (argc == 1)); if (ret) { return ret; @@ -401,7 +401,7 @@ static int cmd_shell_stats_show(const struct shell *shell, size_t argc, return -ENOEXEC; } - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell_fprintf(shell, SHELL_NORMAL, "Lost logs: %u\n", @@ -421,7 +421,7 @@ static int cmd_shell_stats_reset(const struct shell *shell, return -ENOEXEC; } - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { shell->stats->log_lost_cnt = 0; @@ -435,10 +435,10 @@ static int cmd_shell_stats(const struct shell *shell, size_t argc, char **argv) ARG_UNUSED(argc); if (shell_help_requested(shell)) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return 1; } else if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); } else { shell_fprintf(shell, SHELL_ERROR, "%s:%s%s\n", argv[0], SHELL_MSG_UNKNOWN_PARAMETER, argv[1]); @@ -452,7 +452,7 @@ static int cmd_resize_default(const struct shell *shell, { ARG_UNUSED(argv); - int ret = shell_cmd_precheck(shell, (argc == 1), NULL, 0); + int ret = shell_cmd_precheck(shell, (argc == 1)); if (ret == 0) { SHELL_VT100_CMD(shell, SHELL_VT100_SETCOL_80); @@ -474,7 +474,7 @@ static int cmd_resize(const struct shell *shell, size_t argc, char **argv) return -ENOEXEC; } - err = shell_cmd_precheck(shell, (argc <= 2), NULL, 0); + err = shell_cmd_precheck(shell, (argc <= 2)); if (err) { return err; } diff --git a/tests/bluetooth/shell/src/main.c b/tests/bluetooth/shell/src/main.c index e5dee2be8f7..ddb47b42150 100644 --- a/tests/bluetooth/shell/src/main.c +++ b/tests/bluetooth/shell/src/main.c @@ -33,7 +33,7 @@ static bool hrs_simulate; static int cmd_hrs_simulate(const struct shell *shell, size_t argc, char *argv[]) { - int err = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + int err = shell_cmd_precheck(shell, (argc == 2)); if (err) { return err; @@ -55,7 +55,7 @@ static int cmd_hrs_simulate(const struct shell *shell, hrs_simulate = false; } else { shell_print(shell, "Incorrect value: %s", argv[1]); - shell_help_print(shell, NULL, 0); + shell_help_print(shell); return -ENOEXEC; } @@ -77,10 +77,10 @@ SHELL_CREATE_STATIC_SUBCMD_SET(hrs_cmds) { static int cmd_hrs(const struct shell *shell, size_t argc, char **argv) { - int err = shell_cmd_precheck(shell, (argc == 2), NULL, 0); + int err = shell_cmd_precheck(shell, (argc == 2)); if (argc == 1) { - shell_help_print(shell, NULL, 0); + shell_help_print(shell); /* shell_cmd_precheck returns 1 when help is printed */ return 1; } diff --git a/tests/shell/src/main.c b/tests/shell/src/main.c index 5d0c2f79576..51a667ce8d3 100644 --- a/tests/shell/src/main.c +++ b/tests/shell/src/main.c @@ -196,7 +196,7 @@ static int cmd_test_module(const struct shell *shell, size_t argc, char **argv) { ARG_UNUSED(argv); - return shell_cmd_precheck(shell, (argc == 1), NULL, 0); + return shell_cmd_precheck(shell, (argc == 1)); } SHELL_CMD_REGISTER(test_shell_cmd, NULL, NULL, cmd_test_module);