generate-cmds.sh: factor out synopsis extract code
This makes it easier to reuse the same code in another place (very soon). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 10, 2018 at 10:46 UTC
75ba897e3059da44ad0cf27d1e4d12dc03e54001
1 file changed
+11
-7
generate-cmdlist.sh
+11
-7
@@ -1,5 +1,15 @@
1
#!/bin/sh
2
3
+get_synopsis () {
4
+ sed -n '
5
+ /^NAME/,/'"$1"'/H
6
+ ${
7
+ x
8
+ s/.*'"$1"' - \(.*\)/N_("\1")/
9
+ p
10
+ }' "Documentation/$1.txt"
11
+}
12
+
13
echo "/* Automatically generated by generate-cmdlist.sh */
14
struct cmdname_help {
15
char name[16];
@@ -39,12 +49,6 @@ sort |
49
while read cmd tags
50
do
51
tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
42
- sed -n '
43
- /^NAME/,/git-'"$cmd"'/H
44
- ${
45
- x
46
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1"), '$tag'},/
47
- p
48
- }' "Documentation/git-$cmd.txt"
52
+ echo " {\"$cmd\", $(get_synopsis git-$cmd), $tag},"
53
done
54
echo "};"