[PATCH 0 of 1] Display type of each command options in online help document.

FUJIWARA Katsunori fujiwara at ascade.co.jp
Thu Feb 12 12:19:14 CST 2009


At Tue, 30 Dec 2008 16:38:53 +0100,
Martin Geisler wrote:

> FUJIWARA Katsunori <fujiwara at ascade.co.jp> writes:
> 
> > I offten see `mercurial/command.py' to confirm type of options: 
> > value requirement and multi-value allowance.
> >
> > So, I wrote patch to display type of each command options in online
> > help document.
> >
> > Current online help displays:
> >
> >  -f --force      force push
> >  -r --rev        a specific revision up to which you would like to push
> >  -e --ssh        specify ssh command to use
> >
> > This patch changes it to:
> >
> >  -f --force     [F] force push
> >  -r --rev       [M] a specific revision up to which you would like to push
> >  -e --ssh       [V] specify ssh command to use
> 
> Instead of a non-standard format, I would prefer the output from the
> standard optparse module. For the push command the options could be
> declared like this:
> 
> From optparse import OptionParser
> parser = OptionParser()
> parser.add_option("-f", "--force", help="force push", action="store_true")
> parser.add_option("-r", "--rev",
>                   help="a specific revision up to which you would like to push")
> parser.add_option("-e", "--ssh", help="specify ssh command to use")
> parser.add_option("--remotecmd", metavar="CMD",
>                   help="specify hg command to run on the remote side")
> parser.parse_args()
> 
> Running the script with -h on the command line gives:
> 
> Options:
>   -h, --help         show this help message and exit
>   -f, --force        force push
>   -r REV, --rev=REV  a specific revision up to which you would like to push
>   -e SSH, --ssh=SSH  specify ssh command to use
>   --remotecmd=CMD    specify hg command to run on the remote side
> 
> -- 
> Martin Geisler
> 
> VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
> SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.

I checked optparse library, and thought as below to keep string under
80 chars:

    - value name label(like "REV") for short form is redundant, so
      omit it

    - using long form name to generate value name label is redundant,
      but good abbreviation is difficult for auto-generation, so use
      "VAL" as value name label for all options

    - optparse library does not have specific help notation for
      multiple value option("append" action for optparse lib) , so add
      "..."  for such options

Now, I plan to use help format shown below:

  -f --force        force push
  -r --rev VAL ...  a specific revision up to which you would like to push
  -e --ssh VAL      specify ssh command to use

What do you think about it ?

--------
[FUJIWARA Katsunori]
fujiwara at ascade.co.jp(foozy at lares.dti.ne.jp)



More information about the Mercurial-devel mailing list