Created
February 16, 2014 10:40
-
-
Save aliles/9032303 to your computer and use it in GitHub Desktop.
Example usage of the new begin.formatters module to preserve whitespace from docstrings in help output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import begin | |
my_formatter = begin.formatters.compose(begin.formatters.RawDescription) | |
@begin.subcommand | |
def sub(): | |
"""Such text | |
Very whitespace | |
So exact | |
""" | |
@begin.start(formatter_class=my_formatter) | |
def main(): | |
"""Plain text formatting for this help: | |
- how does it look? | |
Params: | |
foo is yummy... | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usage: rawhelp.py [-h] {sub} ... | |
Plain text formatting for this help: | |
- how does it look? | |
Params: | |
foo is yummy... | |
optional arguments: | |
-h, --help show this help message and exit | |
Available subcommands: | |
{sub} | |
sub Such text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usage: rawhelp.py sub [-h] | |
Such text | |
Very whitespace | |
So exact | |
optional arguments: | |
-h, --help show this help message and exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment