Message132224
In argparse, you could so something like:
version = "2.7"
parser = argparse.ArgumentParser(
description="My program XXX, version " + version)
parser.add_argument('-v', action='version', version=version)
That would then produce:
usage: PROG [-h] [-v]
My program XXX, version 2.7
optional arguments:
-h, --help show this help message and exit
-v show program's version number and exit
Is that acceptable? This is basically the style of svn:
$ svn help
usage: svn <subcommand> [options] [args]
Subversion command-line client, version 1.6.15.
...
I see though that vi puts the full name and version before the usage (which is currently impossible in argparse):
$ vi --help
VIM - Vi IMproved 7.0 (2006 May 7, compiled Sep 19 2009 17:22:08)
usage: vim [arguments] [file ..] edit specified file(s)
...
Most other programs I tried didn't give a version number at all, though some did give a full name before the usage:
$ hg
Mercurial Distributed SCM
...
$ hg clone --help
hg clone [OPTION]... SOURCE [DEST]
...
$ git
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
...
$ emacs --help
Usage: emacs [OPTION-OR-FILENAME]...
...
I guess we could add, say, a headline= option to ArgumentParser which would then be printed before the usage message if it's really crucial to have that message first... I'd rather not though if the description= approach is acceptable to you, since adding headline= would add more complexity to an already complex ArgumentParser constructor. |
|
Date |
User |
Action |
Args |
2011-03-26 10:20:13 | bethard | set | recipients:
+ bethard, techtonik, sandro.tosi |
2011-03-26 10:20:13 | bethard | set | messageid: <1301134813.4.0.909666638413.issue7284@psf.upfronthosting.co.za> |
2011-03-26 10:20:11 | bethard | link | issue7284 messages |
2011-03-26 10:20:10 | bethard | create | |
|