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 travistouchdown
Recipients travistouchdown
Date 2010-07-28.15:10:38
SpamBayes Score 0.04601282
Marked as misclassified No
Message-id <1280329840.94.0.288179215378.issue9399@psf.upfronthosting.co.za>
In-reply-to
Content
Currently argparse has a 'version' action which can be triggered by user defined options which prints out a custom string.

parser.add_argument("--version", action="version", version="test 1.2.3")

Since the 'version' action can be added multiple times, it can be used to output different kinds of information, like the program's license.

parser.add_argument("--license", action="version", version="This file is licensed under GPL.... [a huge amount of text]")

The only drawback is that linebreaks are substituted with a normal space. So I propose a 'print' action (perhaps as a replacement for 'version'?) which respects whitespace characters.

parser.add_argument("--version", action="print", message="test 1.2.3")
parser.add_argument("--license", action="print", message="This file is licensed under GPL.... [a huge amount of text, now properly formatted!]")
parser.add_argument("--insult-me", action="print", message="You sick *peep* , *peep* yourself in *peep*")

Currently, the only solution is to create a custom action which is IMHO a bit overkill for just printing a simple string to stdout.
History
Date User Action Args
2010-07-28 15:10:41travistouchdownsetrecipients: + travistouchdown
2010-07-28 15:10:40travistouchdownsetmessageid: <1280329840.94.0.288179215378.issue9399@psf.upfronthosting.co.za>
2010-07-28 15:10:39travistouchdownlinkissue9399 messages
2010-07-28 15:10:38travistouchdowncreate