diff --git a/librz/core/cmd/cmd_api.c b/librz/core/cmd/cmd_api.c index c4c7917be83..1b3b336fb68 100644 --- a/librz/core/cmd/cmd_api.c +++ b/librz/core/cmd/cmd_api.c @@ -1140,7 +1140,28 @@ static void do_print_child_help(RzCmd *cmd, RzStrBuf *sb, const RzCmdDesc *cd, c } static void print_child_help(RzCmd *cmd, RzStrBuf *sb, RzCmdDesc *cd, size_t max_len, bool use_color) { - do_print_child_help(cmd, sb, cd, cd->name, cd->help->summary ? cd->help->summary : "", true, max_len, use_color); + void **it_cd; + bool check = false; + + rz_cmd_desc_children_foreach(cd, it_cd) { + RzCmdDesc *child = *(RzCmdDesc **)it_cd; + if (!strcmp(child->name, cd->name)) { + check = true; + } + } + + const char *summary = strdup(cd->help->summary); + size_t summary_len = strlen(summary); + char *newSummary = malloc(strlen(summary) + 32); + + if (check) { + snprintf(newSummary, summary_len + 32, "%s (see %s?? for more details)", summary, cd->name); + summary = newSummary; + } + + do_print_child_help(cmd, sb, cd, cd->name, summary ? summary : "", true, max_len, use_color); + + free(newSummary); } static char *group_get_help(RzCmd *cmd, RzCmdDesc *cd, bool use_color) { diff --git a/test/unit/test_cmd.c b/test/unit/test_cmd.c index 6c8f21370f7..f90391a785a 100644 --- a/test/unit/test_cmd.c +++ b/test/unit/test_cmd.c @@ -661,7 +661,7 @@ bool test_cmd_argv_state(void) { RzCmdParsedArgs *pa = rz_cmd_parsed_args_newcmd("?"); char *h = rz_cmd_get_help(cmd, pa, false); char *exp_h = "Usage: [.][times][cmd][~grep][@[@iter]addr][|>pipe] ; ...\n" - "| z[jqJ] # group summary\n"; + "| z[jqJ] # group summary (see z?? for more details)\n"; mu_assert_streq(h, exp_h, "zj, zJ and zq are considered in the help"); free(h); rz_cmd_parsed_args_free(pa); @@ -709,7 +709,7 @@ bool test_cmd_group_argv_modes(void) { RzCmdParsedArgs *pa = rz_cmd_parsed_args_newcmd("?"); char *h = rz_cmd_get_help(cmd, pa, false); char *exp_h = "Usage: [.][times][cmd][~grep][@[@iter]addr][|>pipe] ; ...\n" - "| z[jqd] # z group summary\n"; + "| z[jqd] # z group summary (see z?? for more details)\n"; mu_assert_streq(h, exp_h, "zd is considered in the help"); free(h); rz_cmd_parsed_args_free(pa);