parse the [groups] block to create the array of group descriptions
static char *common_cmd_groups[] = {
N_("starting a working area"),
N_("working on the current change"),
N_("working with others"),
N_("examining the history and state"),
N_("growing, marking and tweaking your history"),
};
then map each element of common_cmds[] to a group via its index:
static struct cmdname_help common_cmds[] = {
{"add", N_("Add file contents to the index"), 1},
{"branch", N_("List, create, or delete branches"), 4},
{"checkout", N_("Checkout a branch or paths to the working tree"), 4},
{"clone", N_("Clone a repository into a new directory"), 0},
{"commit", N_("Record changes to the repository"), 4},
[...]
So that 'git help' can print those command grouped by theme.
Helped-by: Junio C Hamano [off-list ref]
Helped-by: Eric Sunshine [off-list ref]
Signed-off-by: Sébastien Guimmara <redacted>
---
generate-cmdlist.sh | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 9a4c9b9..724bb8d 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -1,23 +1,42 @@
#!/bin/sh
+content=$(cat command-list.txt)
+
+group_line_no=$(expr $(echo "$content" | grep -n '^\[groups\]' | cut -f1 -d:) + 1)
+command_line_no=$(expr $(echo "$content" | grep -n '^\[commands\]' | cut -f1 -d:) + 1)
+groups=$(echo "$content" | sed -n ''$group_line_no', '$(expr $command_line_no)'p')
echo "/* Automatically generated by $0 */
+
struct cmdname_help {
char name[16];
char help[80];
+ unsigned char group;
};
+static char *common_cmd_groups[] = {"
+echo "$groups" |
+while read group description; do
+ if [ -z $group ]; then
+ break
+ fi
+ echo ' N_("'$description'"),'
+done
+echo "};
+
static struct cmdname_help common_cmds[] = {"
-sed -n -e 's/^git-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/git-'"$cmd"'/H
- ${
- x
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1")},/
- p
- }' "Documentation/git-$cmd.txt"
+echo "$content" | grep 'common-' |
+awk '{ print $1, "\t", $3 }' |
+while read cmd grp; do
+ cmd_name=$(echo $cmd | cut -d - -f 2)
+ group_name=$(echo $grp | cut -d - -f 2)
+ group_idx=$(expr $(echo "$groups" | grep -n "^$group_name" | cut -c 1) - 1)
+ sed -n '
+ /^NAME/,/git-'"$cmd_name"'/H
+ ${
+ x
+ s/.*git-'"$cmd_name"' - \(.*\)/ {"'"$cmd_name"'", N_("\1"), '"$group_idx"'},/
+ p
+ }' "Documentation/$cmd.txt"
done
-echo "};"
+echo "};"\ No newline at end of file
--
2.4.0