Allow 'help' command to print help for multiple commands at once

This commit is contained in:
Asmageddon 2012-05-29 15:24:55 +02:00
commit 2ed60de628

View file

@ -49,21 +49,19 @@ class Command(BaseCommand):
self._commands = self.console._commands self._commands = self.console._commands
deferred = defer.succeed(True) deferred = defer.succeed(True)
if args: if args:
if len(args) > 1: for arg in args:
self.console.write(usage) try:
return deferred cmd = self._commands[arg]
try: except KeyError:
cmd = self._commands[args[0]] self.console.write("{!error!}Unknown command %r" % args[0])
except KeyError: continue
self.console.write("{!error!}Unknown command %r" % args[0]) try:
return deferred parser = cmd.create_parser()
try: self.console.write(parser.format_help())
parser = cmd.create_parser() except AttributeError, e:
self.console.write(parser.format_help()) self.console.write(cmd.__doc__ or 'No help for this command')
except AttributeError, e: self.console.write(" ")
self.console.write(cmd.__doc__ or 'No help for this command')
else: else:
max_length = max( len(k) for k in self._commands)
self.console.set_batch_write(True) self.console.set_batch_write(True)
for cmd in sorted(self._commands): for cmd in sorted(self._commands):
self.console.write("{!info!}" + cmd + "{!input!} - " + self._commands[cmd].__doc__ or '') self.console.write("{!info!}" + cmd + "{!input!} - " + self._commands[cmd].__doc__ or '')