projects
/
mw
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add capability for subcommand shortcuts
[mw]
/
src
/
mw
/
cli.py
diff --git
a/src/mw/cli.py
b/src/mw/cli.py
index 7f5b4bcd00cc15003212a3fc02408a0e3c0d223b..7dc49c5600286fdc11688507a9d9b97875f39656 100644
(file)
--- a/
src/mw/cli.py
+++ b/
src/mw/cli.py
@@
-26,6
+26,7
@@
class CLI(object):
def __init__(self):
self.me = os.path.basename(sys.argv[0])
self.commands = {}
def __init__(self):
self.me = os.path.basename(sys.argv[0])
self.commands = {}
+ self.shortcuts = {}
for name in mw.clicommands.__dict__:
if name == 'CommandBase':
continue
for name in mw.clicommands.__dict__:
if name == 'CommandBase':
continue
@@
-34,13
+35,18
@@
class CLI(object):
issubclass(clazz, mw.clicommands.CommandBase):
cmd = clazz()
self.commands[cmd.name] = cmd
issubclass(clazz, mw.clicommands.CommandBase):
cmd = clazz()
self.commands[cmd.name] = cmd
+ self.shortcuts[cmd.name] = cmd.shortcuts
def usage(self):
print 'usage: %s [subcommand]' % self.me
print
for name in self.commands:
cmd = self.commands[name]
def usage(self):
print 'usage: %s [subcommand]' % self.me
print
for name in self.commands:
cmd = self.commands[name]
- print("\t%-14s %-25s" % (name, cmd.description))
+ if len(cmd.shortcuts) > 0:
+ full = name + ' (' + ' '.join(cmd.shortcuts) + ')'
+ else:
+ full = name
+ print("\t%-14s %-25s" % (full, cmd.description))
print
sys.exit(1)
print
sys.exit(1)
Benjamin Mako Hill
||
Want to submit a patch?