only display usable commands in help

With the ability to defer 'init', users can access the help system while
still in CONFIG mode.  This patch omits commands from the help and usage
list when they cannot be run in the current command mode, making it much
easier to see what can be done at a given time.
__archive__
Zachary T Welch 2009-11-29 14:29:24 -08:00
parent cee1f39f18
commit c0630d8a58
1 changed files with 3 additions and 0 deletions

View File

@ -872,6 +872,9 @@ static void command_help_show_wrap(const char *str, unsigned n, unsigned n2)
static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
bool show_help) bool show_help)
{ {
if (!command_can_run(CMD_CTX, c))
return ERROR_OK;
char *cmd_name = command_name(c, ' '); char *cmd_name = command_name(c, ' ');
if (NULL == cmd_name) if (NULL == cmd_name)
return -ENOMEM; return -ENOMEM;