summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-09 18:00:01 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-09 18:00:01 +0100
commit635f280ee4595504e5655da2b7715a911d265295 (patch)
tree65eca39b101602739283032a3bfa1e5307e41bf0
parentb6f560321a30a8aff7adf4efecefb78180847686 (diff)
downloadcliapp-635f280ee4595504e5655da2b7715a911d265295.tar.gz
Make "help" give useful error if subcommand is unknown
-rw-r--r--NEWS2
-rw-r--r--cliapp/app.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index b73544a..6e236f8 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Version 1.UNRELEASED
"help".
* `ssh_runcmd` now has the `tty` keyword argument to enable ssh
allocation of pseudo-TTYs. Patch from Jannis Pohlmann.
+* The `help` subcommand now writes a useful error message, instead of
+ a stack trace, if given an unknown subcommand. Reported by Rob Taylor.
Version 1.20130424
------------------
diff --git a/cliapp/app.py b/cliapp/app.py
index 42b120e..8e280af 100644
--- a/cliapp/app.py
+++ b/cliapp/app.py
@@ -350,6 +350,8 @@ class Application(object):
return '* %%prog %s: %s\n' % (cmd, summary)
def _format_subcommand_help(self, cmd): # pragma: no cover
+ if cmd not in self.subcommands:
+ raise cliapp.AppException('Unknown subcommand %s' % cmd)
method = self.subcommands[cmd]
doc = method.__doc__ or ''
t = doc.split('\n', 1)