Skip to content

Commit

Permalink
generate-cmds.sh: factor out synopsis extract code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pclouds authored and gitster committed May 10, 2018
1 parent fe0a9ea commit 75ba897
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions generate-cmdlist.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/sh

get_synopsis () {
sed -n '
/^NAME/,/'"$1"'/H
${
x
s/.*'"$1"' - \(.*\)/N_("\1")/
p
}' "Documentation/$1.txt"
}

echo "/* Automatically generated by generate-cmdlist.sh */
struct cmdname_help {
char name[16];
Expand Down Expand Up @@ -39,12 +49,6 @@ sort |
while read cmd tags
do
tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
sed -n '
/^NAME/,/git-'"$cmd"'/H
${
x
s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1"), '$tag'},/
p
}' "Documentation/git-$cmd.txt"
echo " {\"$cmd\", $(get_synopsis git-$cmd), $tag},"
done
echo "};"

0 comments on commit 75ba897

Please sign in to comment.