diff tests/example2.py @ 7:0abe38b2ea7b

example with mandatory arguments; b0rken
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 30 Mar 2012 10:18:34 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/example2.py	Fri Mar 30 10:18:34 2012 -0700
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+from commandparser import CommandParser
+
+
+class Example(object):
+    """
+    an example with a mandatory class argument
+    """
+
+    def __init__(self, foo):
+        """
+        - foo: a string
+        """
+        self.foo = foo
+
+    def execute(self, arg=None):
+        """
+        do something stupid
+        - arg: a pointless argument
+        """
+        print ':'.join([self.foo, str(arg)])
+
+if __name__ == '__main__':
+    import sys
+    parser = CommandParser(Example)
+    parser.invoke(sys.argv[1:])