Skip to content
Permalink
Browse files

shell: Use conditional commands registeration in shell_cmds.c

Modified commands which depends on compile time flags to
use conditional macros.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
  • Loading branch information...
nordic-krch authored and nashif committed Feb 4, 2019
1 parent 7e26f53 commit ecf2784fe7e7c27cf19f891153a7310134611892
Showing with 6 additions and 24 deletions.
  1. +6 −24 subsys/shell/shell_cmds.c
@@ -297,11 +297,6 @@ static int cmd_history(const struct shell *shell, size_t argc, char **argv)
size_t i = 0;
u16_t len;

if (!IS_ENABLED(CONFIG_SHELL_HISTORY)) {
shell_error(shell, "Command not supported.");
return -ENOEXEC;
}

while (1) {
shell_history_get(shell->history, true,
shell->ctx->temp_buff, &len);
@@ -326,11 +321,6 @@ static int cmd_shell_stats_show(const struct shell *shell, size_t argc,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!IS_ENABLED(CONFIG_SHELL_STATS)) {
shell_error(shell, "Command not supported.");
return -ENOEXEC;
}

shell_print(shell, "Lost logs: %u", shell->stats->log_lost_cnt);

return 0;
@@ -342,11 +332,6 @@ static int cmd_shell_stats_reset(const struct shell *shell,
ARG_UNUSED(argc);
ARG_UNUSED(argv);

if (!IS_ENABLED(CONFIG_SHELL_STATS)) {
shell_error(shell, "Command not supported.");
return -ENOEXEC;
}

shell->stats->log_lost_cnt = 0;

return 0;
@@ -369,11 +354,6 @@ static int cmd_resize(const struct shell *shell, size_t argc, char **argv)
{
int err;

if (!IS_ENABLED(CONFIG_SHELL_CMDS_RESIZE)) {
shell_error(shell, "Command not supported.");
return -ENOEXEC;
}

if (argc != 1) {
shell_error(shell, "%s:%s%s", argv[0],
SHELL_MSG_UNKNOWN_PARAMETER, argv[1]);
@@ -427,7 +407,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(m_sub_shell,
SHELL_HELP_BACKSPACE_MODE, NULL),
SHELL_CMD(colors, &m_sub_colors, SHELL_HELP_COLORS, NULL),
SHELL_CMD_ARG(echo, &m_sub_echo, SHELL_HELP_ECHO, cmd_echo, 1, 1),
SHELL_CMD(stats, &m_sub_shell_stats, SHELL_HELP_STATISTICS, NULL),
SHELL_COND_CMD(CONFIG_SHELL_STATS, stats, &m_sub_shell_stats,
SHELL_HELP_STATISTICS, NULL),
SHELL_SUBCMD_SET_END
);

@@ -440,6 +421,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(m_sub_resize,
SHELL_CMD_ARG_REGISTER(clear, NULL, SHELL_HELP_CLEAR, cmd_clear, 1, 0);
SHELL_CMD_REGISTER(shell, &m_sub_shell, SHELL_HELP_SHELL, NULL);
SHELL_CMD_ARG_REGISTER(help, NULL, SHELL_HELP_HELP, cmd_help, 1, 255);
SHELL_CMD_ARG_REGISTER(history, NULL, SHELL_HELP_HISTORY, cmd_history, 1, 0);
SHELL_CMD_ARG_REGISTER(resize, &m_sub_resize, SHELL_HELP_RESIZE, cmd_resize,
1, 1);
SHELL_COND_CMD_ARG_REGISTER(CONFIG_SHELL_HISTORY, history, NULL,
SHELL_HELP_HISTORY, cmd_history, 1, 0);
SHELL_COND_CMD_ARG_REGISTER(CONFIG_SHELL_CMDS_RESIZE, resize, &m_sub_resize,
SHELL_HELP_RESIZE, cmd_resize, 1, 1);

0 comments on commit ecf2784

Please sign in to comment.
You can’t perform that action at this time.