Message111824
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. |
|
Date |
User |
Action |
Args |
2010-07-28 15:10:41 | travistouchdown | set | recipients:
+ travistouchdown |
2010-07-28 15:10:40 | travistouchdown | set | messageid: <1280329840.94.0.288179215378.issue9399@psf.upfronthosting.co.za> |
2010-07-28 15:10:39 | travistouchdown | link | issue9399 messages |
2010-07-28 15:10:38 | travistouchdown | create | |
|