Skip to content

Instantly share code, notes, and snippets.

@naquad
Created July 20, 2012 12:32
Show Gist options
  • Save naquad/3150493 to your computer and use it in GitHub Desktop.
Save naquad/3150493 to your computer and use it in GitHub Desktop.
def _command(self, parser = default_parser, name = None):
def wrap(func):
if not inspect.isfunction(func):
raise RuntimeError, "Only functions allowed to be decorated as command!"
if not name:
name = func.__name__
if not hasattr(func, '__doc__') or not func.__doc__:
raise RuntimeError, "%s must have documentation!" % (name,)
if parser not in self.commands:
self.commands[parser] = {}
self.commands[parser][name] = func
return func
return wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment