diff options
author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-06-30 14:07:01 +0200 |
---|---|---|
committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-07-15 12:28:54 +0200 |
commit | 81edb044ae18a6d71f75559a8fb46fe125af17aa (patch) | |
tree | 5b489ed32cee3b993791fa602e1095c39d4ca14d /src | |
parent | ca42c4b11ae1ec58deb48c20231ca51fb41adef7 (diff) | |
download | nbb-81edb044ae18a6d71f75559a8fb46fe125af17aa.tar.gz nbb-81edb044ae18a6d71f75559a8fb46fe125af17aa.tar.xz nbb-81edb044ae18a6d71f75559a8fb46fe125af17aa.zip |
Automatically adapt width command field in help
Diffstat (limited to 'src')
-rw-r--r-- | src/nbblib/commands.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nbblib/commands.py b/src/nbblib/commands.py index 5fe6e98..1b50dc3 100644 --- a/src/nbblib/commands.py +++ b/src/nbblib/commands.py @@ -119,9 +119,17 @@ class HelpCommand(Command): def _print_command_list(self): print "List of commands:" keys = Command.plugins.keys() + if not keys: + print "Error: No commands found." + sys.exit(2) keys.sort() + keys2 = Command.plugins.keys() + keys2.sort(lambda a,b: cmp(len(b),len(a))) + print "keys ", keys + print "keys2", keys2 + fmt = "\t%%-%ds\t%%s" % len(keys2[0]) for k in keys: - print "\t%-15s\t%s" % (k, Command.plugins[k].summary) + print fmt % (k, Command.plugins[k].summary) def _print_command_help(self, cmd): """print help for command cmd""" |