summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>2007-08-14 11:47:38 +0200
committerNicolas Chauvat <nicolas.chauvat@logilab.fr>2007-08-14 11:47:38 +0200
commitdd10488bf84192437b74d3fd46b8b50131451a19 (patch)
treee58ce738d26421edd5bee78ac36255b718a91027
parent71ccbcb042bf7e994b2c16a9eb8e34ed9ccaf46c (diff)
downloadlogilab-common-dd10488bf84192437b74d3fd46b8b50131451a19.tar.gz
add summary taken from docstring to list of available commands
-rw-r--r--clcommands.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/clcommands.py b/clcommands.py
index 8d3676f..3ecd6b6 100644
--- a/clcommands.py
+++ b/clcommands.py
@@ -90,12 +90,17 @@ def main_usage(status=0, __doc__=None, copyright=DEFAULT_COPYRIGHT):
commands.sort()
doc = __doc__ % ('<command>', '<command arguments>',
'''\
-Type "%%prog <command> --help" for more information about a specific
-command. Available commands are :\n * %s.
-''' % '\n * '.join(commands))
+Type "%prog <command> --help" for more information about a specific
+command. Available commands are :\n''')
doc = doc.replace('%prog', basename(sys.argv[0]))
print 'usage:', doc
- print copyright
+ max_len = max(len(cmd) for cmd in commands)
+ padding = ' '*max_len
+ for command in commands:
+ cmd = _COMMANDS[command]
+ title = cmd.__doc__.split('.')[0]
+ print ' ', (command+padding)[:max_len], title
+ print '\n', copyright
sys.exit(status)