# HG changeset patch # User Jeff Hammel # Date 1333126438 25200 # Node ID 005e073dc590a233929b1f0010c18991384a147b # Parent 5f31e56eebb66e103ae148c7d8537492a7eebb50 basic POC diff -r 5f31e56eebb6 -r 005e073dc590 commandparser/command.py --- a/commandparser/command.py Fri Mar 30 09:46:46 2012 -0700 +++ b/commandparser/command.py Fri Mar 30 09:53:58 2012 -0700 @@ -159,12 +159,12 @@ else: args = argspec.args[1:] optional = None - command = { 'doc': doc, - 'name': name, - 'args': args, - 'optional': optional, - 'varargs': argspec.varargs - } + command = {'doc': doc, + 'name': name, + 'args': args, + 'optional': optional, + 'varargs': argspec.varargs + } return command def commandargs2str(self, command): diff -r 5f31e56eebb6 -r 005e073dc590 tests/example.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/example.py Fri Mar 30 09:53:58 2012 -0700 @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from commandparser import CommandParser + + +class Example(object): + """ + a random example + """ + + def __init__(self, foo=1, bar='fleem'): + """ + - foo: a number + - bar: a string + """ + self.foo = foo + self.bar = bar + + def execute(self, number): + """ + do some stupid math + - number: a number to multiply by foo + """ + return self.foo * int(number) + +if __name__ == '__main__': + import sys + parser = CommandParser(Example) + parser.invoke(sys.argv[1:])