diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-09-24 13:10:46 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-09-24 13:10:46 +0000 |
commit | 323de5b34000982dcee5f158b81d1a8d62892ce7 (patch) | |
tree | dcef5ea6f568398ef155eb7734adfb750a3b1506 | |
parent | 941a2d097880e74bc0efa8b7f23086d71ec3f6c6 (diff) | |
download | morph-323de5b34000982dcee5f158b81d1a8d62892ce7.tar.gz |
Avoid formatting "morph help foo" output
The cliapp formatting doesn't understand Markdown. Adding
Markdown support in Morph is more work than there is time
for right now, but we'll do it later. This quick hack just
means we output the raw Markdown rather than something that
is incomprehensible due to ruined formatting.
-rw-r--r-- | morphlib/app.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index 0890a786..08b020ff 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -418,3 +418,28 @@ class Morph(cliapp.Application): # run the command line return cliapp.Application.runcmd(self, argv, *args, **kwargs) + + # FIXME: This overrides a private method in cliapp. We need + # get cliapp to provide the necessary hooks to do this cleanly. + # As it is, this is a copy of the method in cliapp, with the + # single change that for subcommand helps, the formatting is + # not used. + 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) + + if args: + usage = self._format_usage_for(args[0]) + description = self._format_subcommand_help(args[0]) + text = '%s\n\n%s' % (usage, description) + else: + usage = self._format_usage(all=show_all) + description = fmt.format(self._format_description(all=show_all)) + text = '%s\n\n%s' % (usage, description) + + text = self.settings.progname.join(text.split('%prog')) + self.output.write(text) |