* show one line description for commands in general help
* less frightening message for normal errors
This commit is contained in:
@@ -35,7 +35,7 @@ def handle_exception(exception, value, tb):
|
|||||||
ui.error(_("Keyboard Interrupt: Exiting..."))
|
ui.error(_("Keyboard Interrupt: Exiting..."))
|
||||||
exit()
|
exit()
|
||||||
elif isinstance(value, pisi.Error):
|
elif isinstance(value, pisi.Error):
|
||||||
ui.error(_("Fatal Error. Program Terminated."))
|
ui.error(_("Program Terminated."))
|
||||||
show_traceback = ctx.get_option('debug')
|
show_traceback = ctx.get_option('debug')
|
||||||
elif isinstance(value, pisi.Exception):
|
elif isinstance(value, pisi.Exception):
|
||||||
show_traceback = True
|
show_traceback = True
|
||||||
@@ -51,7 +51,10 @@ Please file a bug report. (http://bugs.uludag.org.tr)"""))
|
|||||||
for e in value.args:
|
for e in value.args:
|
||||||
v += str(e) + '\n'
|
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."))
|
ui.info(_("Please use 'pisi help' for general help."))
|
||||||
|
|
||||||
|
|||||||
@@ -37,15 +37,18 @@ class Command(object):
|
|||||||
cmd = []
|
cmd = []
|
||||||
cmd_dict = {}
|
cmd_dict = {}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def commands_string():
|
def commands_string():
|
||||||
s = ''
|
s = ''
|
||||||
list = [x.name[0] for x in Command.cmd]
|
list = [x.name[0] for x in Command.cmd]
|
||||||
list.sort()
|
list.sort()
|
||||||
for x in list:
|
for name in list:
|
||||||
s += x + '\n'
|
command = Command.get_command(name)
|
||||||
|
summary = command.__doc__.split('\n')[0]
|
||||||
|
s += '%25s - %s\n' % (command.format_name(), summary)
|
||||||
return s
|
return s
|
||||||
commands_string = staticmethod(commands_string)
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def get_command(cmd, fail=False):
|
def get_command(cmd, fail=False):
|
||||||
|
|
||||||
if Command.cmd_dict.has_key(cmd):
|
if Command.cmd_dict.has_key(cmd):
|
||||||
@@ -55,7 +58,6 @@ class Command(object):
|
|||||||
raise Error(_("Unrecognized command: %s") % cmd)
|
raise Error(_("Unrecognized command: %s") % cmd)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
get_command = staticmethod(get_command)
|
|
||||||
|
|
||||||
# instance variabes
|
# instance variabes
|
||||||
|
|
||||||
@@ -205,6 +207,7 @@ If run without parameters, it prints the general help."""
|
|||||||
name = ("help", "h")
|
name = ("help", "h")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
if not self.args:
|
if not self.args:
|
||||||
self.parser.set_usage(usage_text)
|
self.parser.set_usage(usage_text)
|
||||||
pisi.cli.printu(self.parser.format_help())
|
pisi.cli.printu(self.parser.format_help())
|
||||||
|
|||||||
Reference in New Issue
Block a user