From: "lufia via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, lufia <lufia@lufia.org>
Subject: [PATCH 4/6] Port generate-cmdline.sh to rc
Date: Sat, 03 Aug 2019 16:52:12 -0700 (PDT) [thread overview]
Message-ID: <d25bcb43e1d8fe68717c6df57063427ab5a142f4.1564876327.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.305.git.gitgitgadget@gmail.com>
From: lufia <lufia@lufia.org>
Signed-off-by: lufia <lufia@lufia.org>
---
generate-cmdlist.rc | 102 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 102 insertions(+)
create mode 100755 generate-cmdlist.rc
diff --git a/generate-cmdlist.rc b/generate-cmdlist.rc
new file mode 100755
index 0000000000..18699ea9c4
--- /dev/null
+++ b/generate-cmdlist.rc
@@ -0,0 +1,102 @@
+#!/bin/rc
+
+rfork e
+
+fn die {
+ echo $* >[1=2]
+ exit die
+}
+
+fn command_list {
+ grep -v '^#' $1
+}
+
+fn get_categories {
+ tr ' ' '\x0a'|
+ grep -v '^$' |
+ sort |
+ uniq
+}
+
+fn category_list {
+ command_list $1 |
+ awk '{ print substr($0, 40) }' |
+ get_categories
+}
+
+fn get_synopsis {
+ sed -n '
+ /^NAME/,/'$1'/h
+ ${
+ x
+ s/.*'$1' - (.*)/N_\("\1"\)/
+ p
+ }' Documentation/$1.txt
+}
+
+fn define_categories {
+ echo
+ echo '/* Command categories */'
+ bit=0
+ category_list $1 |
+ while(cat=`{read}){
+ echo '#define CAT_'$"cat' (1UL << '$bit')'
+ bit=`{hoc -e $bit' + 1'}
+ }
+ test $bit -gt 32 && die 'Urgh.. too many categories?'
+}
+
+fn define_category_names {
+ echo
+ echo '/* Category names */'
+ echo 'static const char *category_names[] = {'
+ bit=0
+ category_list $1 |
+ while(cat=`{read}){
+ echo ' "'$"cat'", /* (1UL << '$bit') */'
+ bit=`{hoc -e $bit' + 1'}
+ }
+ echo ' NULL,'
+ echo '};'
+}
+
+fn print_command_list {
+ echo 'static struct cmdname_help command_list[] = {'
+
+ command_list $1 |
+ while(a=`{read}){
+ s=`{get_synopsis $a(1)}
+ q=`{seq 2 $#a}
+ echo -n ' { "'^$a(1)^'", '$"s', 0'
+ for(cat in `{echo $a($q) | get_categories})
+ echo -n ' | CAT_'^$cat
+ echo ' },'
+ }
+ echo '};'
+}
+
+fn print_config_list {
+ echo 'static const char *config_name_list[] = {'
+ grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
+ sed '/deprecated/d; s/::$//; s/, */\n/g' |
+ sort |
+ while(line=`{read})
+ echo ' "'$"line'",'
+ echo ' NULL'
+ echo '};'
+}
+
+echo '/* Automatically generated by generate-cmdlist.sh */
+struct cmdname_help {
+ const char *name;
+ const char *help;
+ uint32_t category;
+};
+'
+define_categories $1
+echo
+define_category_names $1
+echo
+print_command_list $1
+echo
+print_config_list
--
gitgitgadget
next prev parent reply other threads:[~2019-08-03 23:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-03 23:52 [PATCH 0/6] Port git to Plan 9 KADOTA, Kyohei via GitGitGadget
2019-08-03 23:52 ` [PATCH 1/6] Change HOME, PATH, and .gitconfig paths to be customizable lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 2/6] Fix C syntactic errors for the Plan 9 C compiler lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr lufia via GitGitGadget
2019-08-05 22:37 ` Junio C Hamano
2019-08-03 23:52 ` lufia via GitGitGadget [this message]
2019-08-03 23:52 ` [PATCH 5/6] Add plan9/wrap.c lufia via GitGitGadget
2019-08-04 0:03 ` brian m. carlson
2019-08-04 1:26 ` Kyohei Kadota
2019-08-03 23:52 ` [PATCH 6/6] Add mkfile to build git and subcommands for Plan 9 lufia via GitGitGadget
2019-08-04 0:38 ` [PATCH 0/6] Port git to " brian m. carlson
2019-08-04 2:22 ` Kyohei Kadota
2019-08-04 20:22 ` Jonathan Nieder
2019-08-27 13:46 ` [PATCH v2 0/3] " KADOTA, Kyohei via GitGitGadget
2019-08-27 13:46 ` [PATCH v2 1/3] Change HOME, PATH, and .gitconfig paths to be customizable lufia via GitGitGadget
2019-08-27 13:46 ` [PATCH v2 2/3] Fix C syntactic errors for the Plan 9 C compiler lufia via GitGitGadget
2019-08-27 13:46 ` [PATCH v2 3/3] Support Plan 9 dialect lufia via GitGitGadget
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d25bcb43e1d8fe68717c6df57063427ab5a142f4.1564876327.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lufia@lufia.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).