diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-06-09 18:00:01 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-06-09 18:00:01 +0100 |
commit | 635f280ee4595504e5655da2b7715a911d265295 (patch) | |
tree | 65eca39b101602739283032a3bfa1e5307e41bf0 | |
parent | b6f560321a30a8aff7adf4efecefb78180847686 (diff) | |
download | cliapp-635f280ee4595504e5655da2b7715a911d265295.tar.gz |
Make "help" give useful error if subcommand is unknown
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | cliapp/app.py | 2 |
2 files changed, 4 insertions, 0 deletions
@@ -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) |