For menus with long list of entries, it is useful to be able invoke help message for an individual entry to look up command description and synopsis. Can be invoked by entering "<command> help" or "<command> --help". --- src/shared/shell.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/shared/shell.c b/src/shared/shell.c index c0de1640d..07eaa1702 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -352,6 +352,16 @@ static int cmd_exec(const struct bt_shell_menu_entry *entry, int flags = WRDE_NOCMD; bool optargs = false; + if (argc == 2 && (!memcmp(argv[1], "help", 4) || + !memcmp(argv[1], "--help", 6))) { + printf("%s\n", entry->desc); + printf(COLOR_HIGHLIGHT "Usage:" COLOR_OFF "\n"); + printf("\t %s %-*s\n", entry->cmd, + (int)(CMD_LENGTH - strlen(entry->cmd)), + !entry->arg ? "" : entry->arg); + return 0; + } + if (!entry->arg || entry->arg[0] == '\0') { if (argc > 1) { print_text(COLOR_HIGHLIGHT, "Too many arguments"); -- 2.26.3