git help -t <topic>: list the help of the commands in a given topic
With 'git help -t' lists the available topics.
Show a hint to get a longer list when listing the common commands.
---
To apply on top of cc/help
Documentation/git-help.txt | 41 +++++++++++++++++++++++++++++- command-list.txt | 12 +++++++++ generate-cmdlist.sh | 37 ++++++++++++++++++++++----- help.c | 59 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 132 insertions(+), 17 deletions(-)
Documentation/git-help.txt +40 -1
@@ -7,7 +7,7 @@ git-help - display help information about git SYNOPSIS -------- -'git help' [-a|--all|-i|--info|-w|--web] [COMMAND] +'git help' [-a|--all|-i|--info|-w|--web|-t [topic]] [COMMAND] DESCRIPTION -----------
@@ -16,6 +16,9 @@ With no options and no COMMAND given, the synopsis of the 'git' command and a list of the most commonly used git commands are printed on the standard output. +If the option '-t <topic>' is given, then all the commands on a given +topic are printed, and without a <topic> to get a list of topics. + If the option '--all' or '-a' is given, then all available commands are printed on the standard output.
@@ -54,6 +57,42 @@ is available in PATH. Note that the script tries, as much as possible, to display the HTML page in a new tab on an already opened browser. +-t <topic>:: + Prints all the commands on a given topic, or all the topics. + +TOPICS +------ + +common:: + The most commonly used commands. + +main:: + The main commands. + +interrogators:: + The interrogators commands. + +manipulators:: + The manipulators commands. + +synching:: + The commands to synchronize repositories. + +foreignscm:: + The commands dealing with foreign SCM. + +plumbinginterrogators:: + The low-level interrogators commands. + +plumbingmanipulators:: + The low-level manipulators commands. + +purehelpers:: + The helpers commands. + +synchelpers:: + The helpers commands to synchronize repositories. + Author ------ Written by Junio C Hamano <[email protected]> and the git-list
command-list.txt +12 -0
@@ -128,3 +128,15 @@ git-verify-pack plumbinginterrogators git-verify-tag ancillaryinterrogators git-whatchanged ancillaryinterrogators git-write-tree plumbingmanipulators +# List of known git topics. +# topic name category [common] +topic-common mainporcelain common +topic-main mainporcelain +topic-interrogators ancillaryinterrogators +topic-manipulators ancillarymanipulators +topic-synching synchingrepositories +topic-foreignscm foreignscminterface +topic-plumbinginterrogators plumbinginterrogators +topic-plumbingmanipulators plumbingmanipulators +topic-purehelpers purehelpers +topic-synchelpers synchelpers
generate-cmdlist.sh +30 -7
@@ -1,24 +1,47 @@ #!/bin/sh echo "/* Automatically generated by $0 */ +#define COMMON (1<<1) + struct cmdname_help { - char name[16]; + char name[23]; char help[80]; + char category[22]; + int option; }; -static struct cmdname_help common_cmds[] = {" +static struct cmdname_help cmd_list[] = {" -sed -n -e 's/^git-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt | -sort | -while read cmd +sed -n -e 's/^git-\([^ ]*\)\(.*\)$/\1\2/p' command-list.txt | +grep -v deprecated | sort | +while read cmd topic flag do + flag=$(echo $flag | tr '[a-z]' '[A-Z]') + [ -z "$flag" ] && flag="0" sed -n ' - /NAME/,/git-'"$cmd"'/H + /^NAME$/,/git-'"$cmd"'/H ${ x - s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ + s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1",/ p }' "Documentation/git-$cmd.txt" + echo "\"$topic\", $flag }," +done +echo "};" + +echo "static struct cmdname_help topic_list[] = {" +sed -n -e 's/^topic-\([^ ]*\)\(.*\)$/\1\2/p' command-list.txt | +while read topic category flag +do + flag=$(echo $flag | tr '[a-z]' '[A-Z]') + [ -z "$flag" ] && flag="0" + sed -n ' + /^'$topic'::$/{ + n + s/^[ ]*\(.*\)./ {"'"$topic"'", "\1",/ + p + }' "Documentation/git-help.txt" + echo "\"$category\", $flag }," done echo "};"
help.c +50 -9
76 lines not on this page · raw message
Signature · 1 line
1.5.3.7.2094.gff6c
Quoted 3 lines · Santi Béjar
With 'git help -t' lists the available topics.
Show a hint to get a longer list when listing the common commands.
I like the idea of making the categorized command list in git(7) available, and agree with you that renaming common_cmds[] to cmd_list[] and place everything in there would be the way to go.
However, I doubt about your presentation. Who are the intended audience and what is the expected way this is used?
I highly suspect that it would be much easier to use if you add a mode to "git help" that runs the pager over the categoized command list part of git(7) manual page, without taking "show me list of topics" nor "show commands only in this topic" parameters. It is highly unlikely that a user knows which category an obscure command whose name he wants to recall is in, or can guess which category it would be classified in after seeing the "category list". It would be much more likely that he finds it easier to scan (perhaps with "/<string>") the command list with one line description in the pager.
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Santi Béjar
With 'git help -t' lists the available topics.
Quoted 8 lines
Quoted 1 line
Show a hint to get a longer list when listing the common commands.
I like the idea of making the categorized command list in git(7) available, and agree with you that renaming common_cmds[] to cmd_list[] and place everything in there would be the way to go.
However, I doubt about your presentation. Who are the intended audience and what is the expected way this is used?
The main reason for this was to be able to show a longer list in git help. But at the end I did this topic thing. The intented audience was the newbies looking at the "git help" output, for them to have a longer list. Then the topic part was intended for intermidiate user looking for even more powerfull commands.
Quoted 10 lines
I highly suspect that it would be much easier to use if you add a mode to "git help" that runs the pager over the categoized command list part of git(7) manual page, without taking "show me list of topics" nor "show commands only in this topic" parameters. It is highly unlikely that a user knows which category an obscure command whose name he wants to recall is in, or can guess which category it would be classified in after seeing the "category list". It would be much more likely that he finds it easier to scan (perhaps with "/<string>") the command list with one line description in the pager.
OK, this makes sense. But I still think that having a longer list in "git help -l?" with the main porcelain commands makes sense. I'll try to do it.
Best regards,
Santi