Skip to content

Commit 7e07a43

Browse files
ParkSeungHyeoknamhyung
authored andcommitted
uftrace: Add sub-command specific help
This patch adds sub-command specific help by redirecting the help message to their man pages of each command just like git and perf do. The simple usage is as follows. $ uftrace [COMMAND] --help Then you will see the man page of given '[COMMAND]' such as record, replay and so on. Fixed: namhyung#1316 Signed-off-by: Seunghyeok Park <[email protected]>
1 parent c54660b commit 7e07a43

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

uftrace.c

+15
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,19 @@ __used static void apply_default_opts(int *argc, char ***argv, struct uftrace_op
13831383
}
13841384
}
13851385

1386+
__used static void show_man_page(char *cmd)
1387+
{
1388+
char *cmdstr = NULL;
1389+
1390+
if (cmd)
1391+
xasprintf(&cmdstr, "uftrace-%s", cmd);
1392+
else
1393+
cmdstr = xstrdup("uftrace");
1394+
execlp("man", "man", cmdstr, (char *)NULL);
1395+
/* fall through if man command itself is not found */
1396+
free(cmdstr);
1397+
}
1398+
13861399
#ifndef UNIT_TEST
13871400
int main(int argc, char *argv[])
13881401
{
@@ -1428,6 +1441,8 @@ int main(int argc, char *argv[])
14281441
ret = 0;
14291442
goto cleanup;
14301443
case -3:
1444+
if (opts.mode)
1445+
show_man_page(argv[1]);
14311446
if (opts.use_pager)
14321447
start_pager(setup_pager());
14331448
pr_out(uftrace_usage);

0 commit comments

Comments
 (0)