summaryrefslogtreecommitdiff
path: root/cliapp/app.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-02-10 10:54:37 +0000
committerLars Wirzenius <liw@liw.fi>2013-02-10 10:54:37 +0000
commit090dfa309e03eda0637bab9932d2982e2d5aab22 (patch)
treec361028fe5af12fcd278cc70393d84d3f807c640 /cliapp/app.py
parenta1347e9330e00529ccbd0feaf3f05b3c98d52062 (diff)
downloadcliapp-090dfa309e03eda0637bab9932d2982e2d5aab22.tar.gz
Add help-all subcommand
Diffstat (limited to 'cliapp/app.py')
-rw-r--r--cliapp/app.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/cliapp/app.py b/cliapp/app.py
index e6eaeab..cf970e0 100644
--- a/cliapp/app.py
+++ b/cliapp/app.py
@@ -264,6 +264,8 @@ class Application(object):
def add_default_subcommands(self):
if 'help' not in self.subcommands:
self.add_subcommand('help', self.help)
+ if 'help-all' not in self.subcommands:
+ self.add_subcommand('help-all', self.help_all)
def help(self, args): # pragma: no cover
'''Print help.'''
@@ -286,6 +288,28 @@ class Application(object):
text = self.settings.progname.join(text.split('%prog'))
self.output.write(text)
+
+ def help_all(self, args): # pragma: no cover
+ '''Print help, including hidden subcommands.'''
+
+ 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 = fmt.format(self._format_subcommand_help(args[0]))
+ text = '%s\n\n%s' % (usage, description)
+ else:
+ usage = self._format_usage(all=True)
+ description = fmt.format(self._format_description(all=True))
+ text = '%s\n\n%s' % (usage, description)
+
+ text = self.settings.progname.join(text.split('%prog'))
+ self.output.write(text)
def _subcommand_methodnames(self):
return [x