D port of docopt
Bob Tolbert via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon Jun 16 11:19:02 PDT 2014
On Monday, 16 June 2014 at 17:59:13 UTC, Sönke Ludwig wrote:
> Am 15.06.2014 19:35, schrieb Bob Tolbert:
>
> One thing that would be nice is support for multiple help
> screens (e.g. one per command). For DUB [1] (or GIT) for
> example there is one main help screen that lists all commands
> along with common options and then one help screen per command
> that lists the individual arguments, options and a summary of
> what the command does. But maybe for such more complex CLIs it
> starts to be more efficient to use a programmatic approach.
>
if you have a look at the gitD examples, they do just this. If
you do
gitD --help
you get the general help for gitD, but if you do
gitD push -h
or
gitD help push
you get the help for the sub-command "push"
so doing this with 'dub' would be pretty simple.
And you don't have to use external sub-commands either. You can
parse the basic args with the general doc string and then based
on the sub-command chosen, re-parse with the options specific to
that sub module.
I haven't looked at the dub source code, but I'd be happy to help
sketch out how this might work there specifically.
Bob
More information about the Digitalmars-d-announce
mailing list