--version command

9 views
Skip to first unread message

Tomas Neme

unread,
Oct 28, 2013, 5:26:48 PM10/28/13
to argh-...@googlegroups.com
I'd like to have a simple --version switch, with no subcommands to
just print the version number, and I can't find how to do it

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

Andy Mikhailenko

unread,
Oct 29, 2013, 2:08:21 AM10/29/13
to argh-...@googlegroups.com
The best method is to add a special argument to the parser:

parser = argh.ArghParser()
parser.add_commands([foo, bar])
parser.add_argument('--version', action='version', version=__version__)
parser.dispatch()

As you see, this is not Argh-specific. I think it might be a good idea
to also add a shortcut in Argh to enable something like this:

argh.dispatch_command(foo, version=__version__)

If you think so too, please create an issue.

Andy

Tomas Neme

unread,
Oct 29, 2013, 5:01:16 PM10/29/13
to argh-...@googlegroups.com
ah, sounds sensible, since it must be pretty standard.

better still, I can probably send a patch over
Reply all
Reply to author
Forward
0 new messages