summaryrefslogtreecommitdiff
path: root/cliapp/app.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-30 11:51:32 +0000
committerLars Wirzenius <liw@liw.fi>2013-10-30 11:51:32 +0000
commit9c4a905d3985d361f0b5362a5ed6d480a5b09404 (patch)
treeaa01b5c743ea73f6ee1c0f87bbd9193fa32dae48 /cliapp/app.py
parentc8c2b9c9ab7a207b9a202bbfda901d9cb20e863c (diff)
downloadcliapp-9c4a905d3985d361f0b5362a5ed6d480a5b09404.tar.gz
Add method for return help text formatters
Diffstat (limited to 'cliapp/app.py')
-rw-r--r--cliapp/app.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/cliapp/app.py b/cliapp/app.py
index 5e49bf0..abffa45 100644
--- a/cliapp/app.py
+++ b/cliapp/app.py
@@ -270,13 +270,27 @@ class Application(object):
if 'help-all' not in self.subcommands:
self.add_subcommand('help-all', self.help_all)
+ def get_help_text_formatter(self, *args, **kwargs): # pragma: no cover
+ '''Return a help text formatting class.
+
+ The class must have a compatible interface with
+ cliapp.TextFormat.
+
+ This method exists for those applications who want to change
+ how help texts are formatted, e.g., to allow Markdown or
+ reStructuredText.
+
+ '''
+
+ return cliapp.TextFormat(*args, **kwargs)
+
def _help_helper(self, args, show_all): # pragma: no cover
try:
width = int(os.environ.get('COLUMNS', '78'))
except ValueError:
width = 78
- fmt = cliapp.TextFormat(width=width)
+ fmt = self.get_help_text_formatter(width=width)
if args:
usage = self._format_usage_for(args[0])