fixed bug in help command (thanks slav0nic for reporting)

This commit is contained in:
Pablo Hoffman 2009-08-26 16:18:25 -03:00
parent 0e163a9816
commit 625137464f
1 changed files with 15 additions and 4 deletions

View File

@ -1,3 +1,5 @@
import textwrap
from scrapy.command import ScrapyCommand, cmdline
class Command(ScrapyCommand):
@ -14,16 +16,25 @@ class Command(ScrapyCommand):
if not args:
return False
commands = cmdline.builtin_commands_dict()
commands.update(cmdline.custom_commands_dict())
commands = cmdline.get_commands_dict()
cmdname = args[0]
if cmdname in commands:
cmd = commands[cmdname]
help = getattr(cmd, 'help', None) or getattr(cmd, 'long_desc', None)
print "%s: %s" % (cmdname, cmd.short_desc())
title = "%s command" % cmdname
print title
print "-" * len(title)
print
print cmd.short_desc()
print
print "usage: %s %s" % (cmdname, cmd.syntax())
print
print help()
print "\n".join(textwrap.wrap(help()))
print
print "For a list of supported arguments use:"
print
print " scrapy-ctl.py %s -h" % cmdname
print
else:
print "Unknown command: %s" % cmdname