This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bethard
Recipients bethard, sandro.tosi, techtonik
Date 2011-03-26.10:20:10
SpamBayes Score 3.3262187e-10
Marked as misclassified No
Message-id <1301134813.4.0.909666638413.issue7284@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-03-26 10:20:13bethardsetrecipients: + bethard, techtonik, sandro.tosi
2011-03-26 10:20:13bethardsetmessageid: <1301134813.4.0.909666638413.issue7284@psf.upfronthosting.co.za>
2011-03-26 10:20:11bethardlinkissue7284 messages
2011-03-26 10:20:10bethardcreate