From 635f280ee4595504e5655da2b7715a911d265295 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 9 Jun 2013 18:00:01 +0100 Subject: Make "help" give useful error if subcommand is unknown --- NEWS | 2 ++ cliapp/app.py | 2 ++ 2 files changed, 4 insertions(+) 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) -- cgit v1.2.1