diff options
author | Yunlong Song <yunlong.song@huawei.com> | 2015-03-18 09:35:53 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-19 12:49:39 -0400 |
commit | e24a110882949c609c5fb7625b71d8e77264257b (patch) | |
tree | c6c325af910c4b4f664e1c82c7dbb27a9f4fb34f /tools | |
parent | 01b7160bc6674912f6b7043bbf58d66e62e41054 (diff) |
perf tools: Add the bash completion for listing subsubcommands of perf help
The bash completion does not support listing subsubcommands for 'perf
help <TAB>', so fix it.
Example:
Before this patch:
$ perf help <TAB>
$
As shown above, the subsubcommands of perf help does not come out.
After this patch:
$ perf help <TAB>
annotate buildid-cache data evlist inject
kvm lock probe report script
test top
bench buildid-list diff help kmem
list mem record sched stat
timechart trace
As shown above, the subsubcommands of perf help can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426685758-25488-9-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-help.c | 17 | ||||
-rw-r--r-- | tools/perf/perf-completion.sh | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 25d20628212e..36486eade1ef 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -437,7 +437,18 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) | |||
437 | HELP_FORMAT_INFO), | 437 | HELP_FORMAT_INFO), |
438 | OPT_END(), | 438 | OPT_END(), |
439 | }; | 439 | }; |
440 | const char * const builtin_help_usage[] = { | 440 | const char * const builtin_help_subcommands[] = { |
441 | "buildid-cache", "buildid-list", "diff", "evlist", "help", "list", | ||
442 | "record", "report", "bench", "stat", "timechart", "top", "annotate", | ||
443 | "script", "sched", "kmem", "lock", "kvm", "test", "inject", "mem", "data", | ||
444 | #ifdef HAVE_LIBELF_SUPPORT | ||
445 | "probe", | ||
446 | #endif | ||
447 | #ifdef HAVE_LIBAUDIT_SUPPORT | ||
448 | "trace", | ||
449 | #endif | ||
450 | NULL }; | ||
451 | const char *builtin_help_usage[] = { | ||
441 | "perf help [--all] [--man|--web|--info] [command]", | 452 | "perf help [--all] [--man|--web|--info] [command]", |
442 | NULL | 453 | NULL |
443 | }; | 454 | }; |
@@ -448,8 +459,8 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) | |||
448 | 459 | ||
449 | perf_config(perf_help_config, &help_format); | 460 | perf_config(perf_help_config, &help_format); |
450 | 461 | ||
451 | argc = parse_options(argc, argv, builtin_help_options, | 462 | argc = parse_options_subcommand(argc, argv, builtin_help_options, |
452 | builtin_help_usage, 0); | 463 | builtin_help_subcommands, builtin_help_usage, 0); |
453 | 464 | ||
454 | if (show_all) { | 465 | if (show_all) { |
455 | printf("\n usage: %s\n\n", perf_usage_string); | 466 | printf("\n usage: %s\n\n", perf_usage_string); |
diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index 535ff72babc7..dbca6a66f401 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh | |||
@@ -143,7 +143,7 @@ __perf_main () | |||
143 | __perfcomp_colon "$evts" "$cur" | 143 | __perfcomp_colon "$evts" "$cur" |
144 | else | 144 | else |
145 | # List subcommands for perf commands | 145 | # List subcommands for perf commands |
146 | if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data) ]]; then | 146 | if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help) ]]; then |
147 | subcmds=$($cmd $prev_skip_opts --list-cmds) | 147 | subcmds=$($cmd $prev_skip_opts --list-cmds) |
148 | __perfcomp_colon "$subcmds" "$cur" | 148 | __perfcomp_colon "$subcmds" "$cur" |
149 | fi | 149 | fi |