From ca0a8aa0427e01ad57b91e9701d0a66b00f95dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Sun, 18 Dec 2005 22:49:34 +0000 Subject: [PATCH] * show one line description for commands in general help * less frightening message for normal errors --- pisi-cli | 9 ++++++--- pisi/cli/commands.py | 13 ++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pisi-cli b/pisi-cli index 7cc6b750..f5dc1dd5 100755 --- a/pisi-cli +++ b/pisi-cli @@ -35,7 +35,7 @@ def handle_exception(exception, value, tb): ui.error(_("Keyboard Interrupt: Exiting...")) exit() elif isinstance(value, pisi.Error): - ui.error(_("Fatal Error. Program Terminated.")) + ui.error(_("Program Terminated.")) show_traceback = ctx.get_option('debug') elif isinstance(value, pisi.Exception): show_traceback = True @@ -50,8 +50,11 @@ Please file a bug report. (http://bugs.uludag.org.tr)""")) v = '' for e in value.args: v += str(e) + '\n' - - ui.error("%s: %s" % (exception, v)) + + if ctx.get_option('debug'): + ui.error("%s: %s" % (exception, v)) + else: + ui.error(v) ui.info(_("Please use 'pisi help' for general help.")) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 272d78a8..ba70683d 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -37,15 +37,18 @@ class Command(object): cmd = [] cmd_dict = {} + @staticmethod def commands_string(): s = '' list = [x.name[0] for x in Command.cmd] list.sort() - for x in list: - s += x + '\n' + for name in list: + command = Command.get_command(name) + summary = command.__doc__.split('\n')[0] + s += '%25s - %s\n' % (command.format_name(), summary) return s - commands_string = staticmethod(commands_string) - + + @staticmethod def get_command(cmd, fail=False): if Command.cmd_dict.has_key(cmd): @@ -55,7 +58,6 @@ class Command(object): raise Error(_("Unrecognized command: %s") % cmd) else: return None - get_command = staticmethod(get_command) # instance variabes @@ -205,6 +207,7 @@ If run without parameters, it prints the general help.""" name = ("help", "h") def run(self): + if not self.args: self.parser.set_usage(usage_text) pisi.cli.printu(self.parser.format_help())