Re: [PATCH] Adding Correct Useage Notification and -h Help flag
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jun 14, 2005, 02:23 UTC
- Message-ID
- <7vmzptbrsg.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <1118713641.8712.10.camel@localhost.localdomain>
>>Added a couple of lines to the git wrapper. Includes Correct >>Useage and available scripts
I like the general direction of making "git" wrapper novice friendly, but have some suggestions to the implementation.
(0) Do not mention that only certain subset is accessible.
Just saying "Available commands are:" would be enough, and
would not leave the end user wondering what he is missing. (1) Instead of explicitly checking for -h, you may want to
structure it like this:#!/bin/sh
cmd="git-$1-script";
shift;
exec $cmd "$@";
echo "Usage: git <subcommand> [<param>...]"
echo 'Available commands are:"
git bar
git foo
...
'
exit 1Alternatively, you could say:
#!/bin/sh
case "$1" in
-h)
echo "Usage: git <subcommand> [<param>...]"
echo 'Available commands are:
git bar
git foo
...
'
exit 0 ;;
esac cmd="git-$1-script";
shift;
exec $cmd "$@";
git -h
exit 1 (2) Maintaining the list of commands by hand in git script
itself have an advantage that you _could_ describe the
options and parameters they take, but you are not doing
that in your patch (hint, hint). If all you give is the list of subcommand names, have
git.in as a source file, and create the "list of available
commands" from the Makefile, like this: === Makefile ===
...
git : git.in
/bin/sh ls -1 git-*-script | \
sed -e 's/git-\(.*\)-script/git \1/' >.git-cmd-list
sed -e '/@@LIST_OF_COMMANDS@@/{s/.*//;r .git-cmd-list;}' <$@.in >$@
rm -f .git-cmd-list === git.in ===
#!/bin/sh cmd="git-$1-script";
shift;
exec $cmd "$@";
echo "Usage: git <subcommand> [<param>...]"
echo 'Available commands are:
@@LIST_OF_COMMANDS@@
'