From: Jonas Fonseca <fonseca@diku.dk>
To: Petr Baudis <pasky@ucw.cz>
Cc: git@vger.kernel.org
Subject: [PATCH] cg-help: dynamically list commands
Date: Sat, 11 Jun 2005 14:37:42 +0200 [thread overview]
Message-ID: <20050611123742.GA1477@diku.dk> (raw)
Use code from the make-cogito-asciidoc script to make the command
listing dynamic and hopefully always up-to-date by grepping the
USAGE strings.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
cg-commit | 2 +-
cg-help | 47 +++++++++++++++++++++--------------------------
2 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -72,7 +72,7 @@
# EDITOR::
# The editor used for entering revision log information.
-USAGE="cg-commit [-mMESSAGE]... [-C] [-e | -E] [FILE]..."
+USAGE="cg-commit [-mMESSAGE]... [-C] [-e | -E] [FILE]... < MESSAGE"
. ${COGITO_LIB}cg-Xlib
diff --git a/cg-help b/cg-help
--- a/cg-help
+++ b/cg-help
@@ -25,6 +25,25 @@ if [ "$1" ]; then
exit 1
fi
+bin_path="$(dirname $0)"
+
+REGULAR_COMMANDS="$(ls $bin_path/cg-* | grep -v cg-admin- | grep -v cg-X)"
+ADVANCED_COMMANDS="$(ls $bin_path/cg-admin-*)"
+
+print_command_listing()
+{
+ for command in "$@"; do
+ cmdname=$(basename $command)
+
+ usage=$(sed -n '/^USAGE=/,0s/.*\(cg-.*\)"/\1/p' < $command)
+ # Some minimal sanity check that we didn't pick up some
+ # random binary named cg-*
+ [ "$usage" ] || continue
+ usage=$(echo "$usage" | sed 's/cg-[^ ]*//')
+ printf " %-17s %s\n" "$cmdname" "$usage"
+ done
+}
+
cat <<__END__
The Cogito version control system $(cg-version)
@@ -32,34 +51,10 @@ The Cogito version control system $(cg-
Usage: cg-COMMAND [ARG]...
Available commands:
- cg-add FILE...
- cg-branch-add BNAME SOURCE_LOC
- cg-branch-ls
- cg-cancel
- cg-clone [-s] SOURCE_LOC [DESTDIR]
- cg-commit [-m"Commit message"]... [-e | -E] [FILE]... < log message
- cg-diff [-c] [-m] [-p] [-r FROM_ID[:TO_ID]] [FILE]...
- cg-export DEST [TREE_ID]
- cg-help [COMMAND]
- cg-init
- cg-log [-c] [-f] [-m] [-r FROM_ID[:TO_ID]] [FILE]...
- cg-merge [-c] [-b BASE_ID] FROM_ID
- cg-mkpatch [-m] [-s] [-r FROM_ID[:TO_ID]]
- cg-patch < patch on stdin
- cg-pull [BNAME]
- cg-restore [FILE]...
- cg-rm FILE...
- cg-seek [COMMIT_ID]
- cg-status
- cg-tag TNAME [COMMIT_ID]
- cg-tag-ls
- cg-update [BNAME]
- cg-version
+$(print_command_listing $REGULAR_COMMANDS)
Advanced (low-level or dangerous) commands:
- cg-admin-ls [-t TREE_ID] [PATH]
- cg-admin-lsobj [OBJTYPE]
- cg-admin-uncommit [-t] [COMMIT_ID]
+$(print_command_listing $ADVANCED_COMMANDS)
These expressions can be used interchangably as "ID"s:
empty string, "this" or "HEAD" (current HEAD)
--
Jonas Fonseca
reply other threads:[~2005-06-11 12:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20050611123742.GA1477@diku.dk \
--to=fonseca@diku.dk \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.