Add help function and check always the keyword arguments.

This commit is contained in:
Bastian Kleineidam 2012-02-12 09:17:07 +01:00
parent 45e54345ed
commit 6699e833b4
1 changed files with 4 additions and 2 deletions

View File

@ -208,7 +208,8 @@ class Baker(object):
self.commands[cmd.name] = cmd self.commands[cmd.name] = cmd
# If default is True, set this as the default command # If default is True, set this as the default command
if default: self.defaultcommand = cmd if default:
self.defaultcommand = cmd
return fn return fn
@ -514,7 +515,7 @@ class Baker(object):
if len(args) > len(posargs) and not cmd.has_varargs: if len(args) > len(posargs) and not cmd.has_varargs:
raise CommandError("Too many arguments to %s: %s" % (cmd.name, " ".join(args))) raise CommandError("Too many arguments to %s: %s" % (cmd.name, " ".join(args)))
if not cmd.has_kwargs: if cmd.keywords:
for k in sorted(kwargs.keys()): for k in sorted(kwargs.keys()):
if k not in cmd.keywords: if k not in cmd.keywords:
raise CommandError("Unknown option --%s" % k) raise CommandError("Unknown option --%s" % k)
@ -570,3 +571,4 @@ _baker = Baker()
command = _baker.command command = _baker.command
run = _baker.run run = _baker.run
test = _baker.test test = _baker.test
help = _baker.print_top_help