Re: [PATCH] Simplify usage string printing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 14, 2007 at 02:01:16PM +0000, Jonas Fonseca wrote:
> Signed-off-by: Jonas Fonseca <fonseca@xxxxxxx>
> ---
>  builtin-branch.c     |    1 -
>  builtin-update-ref.c |    1 -
>  parse-options.c      |    2 +-
>  3 files changed, 1 insertions(+), 3 deletions(-)
> 
>  Pierre Habouzit <madcoder@xxxxxxxxxx> wrote Sat, Oct 13, 2007:
>  > Signed-off-by: Pierre Habouzit <madcoder@xxxxxxxxxx>
>  > ---
>  >  builtin-update-ref.c |   71 +++++++++++++++++++++-----------------------------
>  >  1 files changed, 30 insertions(+), 41 deletions(-)
>  > 
>  > diff --git a/builtin-update-ref.c b/builtin-update-ref.c
>  > index fe1f74c..eafb642 100644
>  > --- a/builtin-update-ref.c
>  > +++ b/builtin-update-ref.c
>  > @@ -1,59 +1,48 @@
>  >  #include "cache.h"
>  >  #include "refs.h"
>  >  #include "builtin.h"
>  > +#include "parse-options.h"
>  >  
>  > -static const char git_update_ref_usage[] =
>  > -"git-update-ref [-m <reason>] (-d <refname> <value> | [--no-deref] <refname> <value> [<oldval>])";
>  > +static const char * const git_update_ref_usage[] = {
>  > +	"",
>  > +	"git-update-ref [options] -d <refname> <oldval>",
>  > +	"git-update-ref [options]    <refname> <newval> [<oldval>]",
>  > +	NULL
>  > +};
> 
>  How about something like this to get rid of these empty strings
>  that look strange?
> 
> 	> ./git update-ref -h
> 	usage: git-update-ref [options] -d <refname> <oldval>
> 	   or: git-update-ref [options]    <refname> <newval> [<oldval>]

  I like the idea, though we may want to have more text to explain some
things about the command, so I'll do something in between that uses or:
until an empty line is met, and just prefix the result with four spaces
else, this way we can have:

usage: git-foo ...
   or: git-foo ...

    Did you know that you can do bar with git-foo ?
    but beware that it cannot do quux.

    -m <reason>           reason of the update
    -d                    deletes the reference
    --no-deref            update <refname> not the one it points to


-- 
·O·  Pierre Habouzit
··O                                                madcoder@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgpjhtABQ33bk.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux