From: "Sébastien Guimmara" <sebastien.guimmara@gmail.com>
To: git@vger.kernel.org
Cc: "Sébastien Guimmara" <sebastien.guimmara@gmail.com>,
gitster@pobox.com, sunshine@sunshineco.com
Subject: [PATCH 2/3] generate-cmdlist.sh: parse common group commands
Date: Mon, 4 May 2015 22:28:09 +0200 [thread overview]
Message-ID: <a787babf25481c99edea6dca5e5f7814601395fe.1430770308.git.sebastien.guimmara@gmail.com> (raw)
In-Reply-To: <cover.1430770308.git.sebastien.guimmara@gmail.com>
In-Reply-To: <cover.1430770308.git.sebastien.guimmara@gmail.com>
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 <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
---
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
next prev parent reply other threads:[~2015-05-04 20:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 20:28 [PATCH 0/3] git help: group common commands by theme Sébastien Guimmara
2015-05-04 20:28 ` [PATCH 1/3] command-list.txt: " Sébastien Guimmara
2015-05-06 6:57 ` Eric Sunshine
2015-05-06 20:58 ` Sébastien Guimmara
2015-05-07 16:50 ` Eric Sunshine
2015-05-07 19:23 ` Johannes Sixt
2015-05-08 10:11 ` Johannes Schindelin
2015-05-08 12:01 ` Andreas Schwab
2015-05-08 13:02 ` Johannes Schindelin
2015-05-08 18:43 ` Sébastien Guimmara
2015-05-08 19:00 ` Eric Sunshine
2015-05-04 20:28 ` Sébastien Guimmara [this message]
2015-05-08 3:20 ` [PATCH 2/3] generate-cmdlist.sh: parse common group commands Eric Sunshine
2015-05-08 3:39 ` Eric Sunshine
2015-05-08 20:55 ` Sébastien Guimmara
2015-05-04 20:28 ` [PATCH 3/3] git help: group common commands by theme Sébastien Guimmara
2015-05-06 3:16 ` Eric Sunshine
2015-05-06 20:31 ` Sébastien Guimmara
2015-05-08 21:08 ` Sébastien Guimmara
2015-05-08 21:17 ` Stefan Beller
2015-05-08 21:19 ` Eric Sunshine
2015-05-08 21:20 ` Sébastien Guimmara
2015-05-06 3:08 ` [PATCH 0/3] " Eric Sunshine
2015-05-06 20:26 ` Sébastien Guimmara
2015-05-06 20:49 ` Eric Sunshine
2015-05-06 3:41 ` Junio C Hamano
2015-05-08 18:00 ` Sébastien Guimmara
2015-05-08 18:53 ` Junio C Hamano
2015-05-06 7:59 ` Matthieu Moy
2015-05-06 17:42 ` Junio C Hamano
2015-05-07 8:42 ` Matthieu Moy
2015-05-07 18:44 ` Junio C Hamano
2015-05-08 8:18 ` Matthieu Moy
2015-05-08 16:19 ` Junio C Hamano
2015-05-07 9:31 ` Emma Jane Hogbin Westby
2015-05-08 18:21 ` Sébastien Guimmara
2015-05-08 18:58 ` Junio C Hamano
2015-05-08 20:08 ` Sébastien Guimmara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a787babf25481c99edea6dca5e5f7814601395fe.1430770308.git.sebastien.guimmara@gmail.com \
--to=sebastien.guimmara@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).