generate-cmdlist: re-implement as shell script
527ec39 (generate-cmdlist: parse common group commands, 2015-05-21)
replaced generate-cmdlist.sh with a more functional Perl version,
generate-cmdlist.perl. The Perl version gleans named tags from a new
"common groups" section in command-list.txt and recognizes those
tags in "command list" section entries in place of the old 'common'
tag. This allows git-help to, not only recognize, but also group
common commands.
Although the tests require Perl, 527ec39 creates an unconditional
dependence upon Perl in the build system itself, which can not be
overridden with NO_PERL. Such a dependency may be undesirable; for
instance, the 'git-lite' package in the FreeBSD ports tree is
intended as a minimal Git installation (which may, for example, be
useful on servers needing only local clone and update capability),
which, historically, has not depended upon Perl[1].
Therefore, revive generate-cmdlist.sh and extend it to recognize
"common groups" and its named tags. Retire generate-cmdlist.perl.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-24 00:31:09 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-05-10 11:46:41 +03:00
|
|
|
die () {
|
|
|
|
echo "$@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
command_list () {
|
2018-05-10 11:46:42 +03:00
|
|
|
grep -v '^#' "$1"
|
2018-05-10 11:46:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get_categories () {
|
|
|
|
tr ' ' '\n'|
|
|
|
|
grep -v '^$' |
|
|
|
|
sort |
|
|
|
|
uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
category_list () {
|
|
|
|
command_list "$1" |
|
|
|
|
cut -c 40- |
|
|
|
|
get_categories
|
|
|
|
}
|
|
|
|
|
2018-05-10 11:46:40 +03:00
|
|
|
get_synopsis () {
|
|
|
|
sed -n '
|
|
|
|
/^NAME/,/'"$1"'/H
|
|
|
|
${
|
|
|
|
x
|
|
|
|
s/.*'"$1"' - \(.*\)/N_("\1")/
|
|
|
|
p
|
|
|
|
}' "Documentation/$1.txt"
|
|
|
|
}
|
|
|
|
|
2018-05-10 11:46:41 +03:00
|
|
|
define_categories () {
|
|
|
|
echo
|
|
|
|
echo "/* Command categories */"
|
|
|
|
bit=0
|
|
|
|
category_list "$1" |
|
|
|
|
while read cat
|
|
|
|
do
|
|
|
|
echo "#define CAT_$cat (1UL << $bit)"
|
|
|
|
bit=$(($bit+1))
|
|
|
|
done
|
|
|
|
test "$bit" -gt 32 && die "Urgh.. too many categories?"
|
|
|
|
}
|
|
|
|
|
2018-05-20 21:40:00 +03:00
|
|
|
define_category_names () {
|
|
|
|
echo
|
|
|
|
echo "/* Category names */"
|
|
|
|
echo "static const char *category_names[] = {"
|
|
|
|
bit=0
|
|
|
|
category_list "$1" |
|
|
|
|
while read cat
|
|
|
|
do
|
|
|
|
echo " \"$cat\", /* (1UL << $bit) */"
|
|
|
|
bit=$(($bit+1))
|
|
|
|
done
|
|
|
|
echo " NULL"
|
|
|
|
echo "};"
|
|
|
|
}
|
|
|
|
|
2018-05-10 11:46:41 +03:00
|
|
|
print_command_list () {
|
|
|
|
echo "static struct cmdname_help command_list[] = {"
|
|
|
|
|
|
|
|
command_list "$1" |
|
|
|
|
while read cmd rest
|
|
|
|
do
|
|
|
|
printf " { \"$cmd\", $(get_synopsis $cmd), 0"
|
|
|
|
for cat in $(echo "$rest" | get_categories)
|
|
|
|
do
|
|
|
|
printf " | CAT_$cat"
|
|
|
|
done
|
|
|
|
echo " },"
|
|
|
|
done
|
|
|
|
echo "};"
|
|
|
|
}
|
|
|
|
|
2016-07-02 03:32:00 +03:00
|
|
|
echo "/* Automatically generated by generate-cmdlist.sh */
|
generate-cmdlist: re-implement as shell script
527ec39 (generate-cmdlist: parse common group commands, 2015-05-21)
replaced generate-cmdlist.sh with a more functional Perl version,
generate-cmdlist.perl. The Perl version gleans named tags from a new
"common groups" section in command-list.txt and recognizes those
tags in "command list" section entries in place of the old 'common'
tag. This allows git-help to, not only recognize, but also group
common commands.
Although the tests require Perl, 527ec39 creates an unconditional
dependence upon Perl in the build system itself, which can not be
overridden with NO_PERL. Such a dependency may be undesirable; for
instance, the 'git-lite' package in the FreeBSD ports tree is
intended as a minimal Git installation (which may, for example, be
useful on servers needing only local clone and update capability),
which, historically, has not depended upon Perl[1].
Therefore, revive generate-cmdlist.sh and extend it to recognize
"common groups" and its named tags. Retire generate-cmdlist.perl.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-24 00:31:09 +03:00
|
|
|
struct cmdname_help {
|
2018-05-10 11:46:41 +03:00
|
|
|
const char *name;
|
|
|
|
const char *help;
|
2018-05-10 11:46:42 +03:00
|
|
|
uint32_t category;
|
generate-cmdlist: re-implement as shell script
527ec39 (generate-cmdlist: parse common group commands, 2015-05-21)
replaced generate-cmdlist.sh with a more functional Perl version,
generate-cmdlist.perl. The Perl version gleans named tags from a new
"common groups" section in command-list.txt and recognizes those
tags in "command list" section entries in place of the old 'common'
tag. This allows git-help to, not only recognize, but also group
common commands.
Although the tests require Perl, 527ec39 creates an unconditional
dependence upon Perl in the build system itself, which can not be
overridden with NO_PERL. Such a dependency may be undesirable; for
instance, the 'git-lite' package in the FreeBSD ports tree is
intended as a minimal Git installation (which may, for example, be
useful on servers needing only local clone and update capability),
which, historically, has not depended upon Perl[1].
Therefore, revive generate-cmdlist.sh and extend it to recognize
"common groups" and its named tags. Retire generate-cmdlist.perl.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-24 00:31:09 +03:00
|
|
|
};
|
2018-05-10 11:46:41 +03:00
|
|
|
"
|
2018-05-10 11:46:43 +03:00
|
|
|
define_categories "$1"
|
|
|
|
echo
|
2018-05-20 21:40:00 +03:00
|
|
|
define_category_names "$1"
|
|
|
|
echo
|
2018-05-10 11:46:43 +03:00
|
|
|
print_command_list "$1"
|