From 9c4a905d3985d361f0b5362a5ed6d480a5b09404 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 30 Oct 2013 11:51:32 +0000 Subject: Add method for return help text formatters --- cliapp/app.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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]) -- cgit v1.2.1