All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cg-help: dynamically list commands
@ 2005-06-11 12:37 Jonas Fonseca
  0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2005-06-11 12:37 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-06-11 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-11 12:37 [PATCH] cg-help: dynamically list commands Jonas Fonseca

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.