Skip to content

Instantly share code, notes, and snippets.

@aliles
Created February 16, 2014 10:40
Show Gist options
  • Save aliles/9032303 to your computer and use it in GitHub Desktop.
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.
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...
"""
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
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