From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Petr Baudis <pasky@suse.cz>
Cc: Bert Wesarg <bert.wesarg@googlemail.com>, git@vger.kernel.org
Subject: [TopGit PATCH] tg.sh: Runtime tg-* command check
Date: Wed, 6 Aug 2008 09:49:24 +0200 [thread overview]
Message-ID: <1218008964-27286-1-git-send-email-bert.wesarg@googlemail.com> (raw)
Check for tg commands at runtime, not the hard coded list inside tg.sh.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
tg.sh | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/tg.sh b/tg.sh
index 03a392b..179f0de 100644
--- a/tg.sh
+++ b/tg.sh
@@ -152,8 +152,21 @@ switch_to_base()
do_help()
{
if [ -z "$1" ] ; then
+ ## Build available commands list for help output
+
+ cmds=
+ sep=
+ for cmd in "@cmddir@"/tg-*; do
+ ! [ -r "$cmd" ] && continue
+ # strip directory part and "tg-" prefix
+ cmd="$(basename "$cmd")"
+ cmd="${cmd#tg-}"
+ cmds="$cmds$sep$cmd"
+ sep="|"
+ done
+
echo "TopGit v0.1 - A different patch queue manager"
- echo "Usage: tg (create|delete|info|patch|summary|update|help) ..."
+ echo "Usage: tg ($cmds|help) ..."
elif [ -f "@sharedir@/tg-$1.txt" ] ; then
cat "@sharedir@/tg-$1.txt"
else
@@ -171,6 +184,8 @@ root_dir="$(git rev-parse --show-cdup)"; root_dir="${root_dir:-.}"
setup_ours
setup_hook "pre-commit"
+[ -d "@cmddir@" ] ||
+ die "No command directory: '@cmddir@'"
## Dispatch
@@ -186,12 +201,13 @@ case "$cmd" in
help)
do_help "$1"
exit 1;;
-create|delete|info|patch|summary|update)
- . "@cmddir@"/tg-$cmd;;
--hooks-path)
# Internal command
echo "@hooksdir@";;
*)
- echo "Unknown subcommand: $cmd" >&2
- exit 1;;
+ [ -r "@cmddir@"/tg-$cmd ] || {
+ echo "Unknown subcommand: $cmd" >&2
+ exit 1
+ }
+ . "@cmddir@"/tg-$cmd;;
esac
--
tg: (e311d15..) t/auto-generate-command-list-for-tg.sh (depends on: master)
next prev reply other threads:[~2008-08-06 7:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 6:43 [TopGit PATCH] tg.sh: it's info/attributes not info/gitattributes Bert Wesarg
2008-08-07 16:39 ` [TopGit PATCH] Makefile: mkdir $(bindir) Bert Wesarg
2008-08-06 8:02 ` [TopGit PATCH] tg.sh: Check for read permissions of help files Bert Wesarg
2008-08-06 7:49 ` Bert Wesarg [this message]
2008-08-06 2:43 ` [PATCH] [TopGit] Pretty print the help creation commands in Makefile Russell Steicke
2008-08-09 0:28 ` Petr Baudis
2008-08-09 7:35 ` [TopGit PATCH] tg.sh: Check for read permissions of help files Bert Wesarg
2008-08-09 8:24 ` Petr Baudis
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=1218008964-27286-1-git-send-email-bert.wesarg@googlemail.com \
--to=bert.wesarg@googlemail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.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 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 NNTP newsgroup(s).