git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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 1
     Alternatively, 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@@
     '
Previous: James PurserNext: James Purser
Message 2 of 6 in “Adding Correct Useage Notification and -h Help flag”
  1. Adding Correct Useage Notification and -h Help flagJames Purser, Jun 14, 2005
  2. Junio C HamanoJun 14, 2005
  3. James PurserJun 14, 2005
  4. James PurserJun 14, 2005
  5. Junio C HamanoJun 14, 2005
  6. James PurserJun 14, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.