view tests/example2.py @ 10:a3599e4db9a4

python 2.4 compatability
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 02 Apr 2012 10:21:59 -0700
parents 0abe38b2ea7b
children
line wrap: on
line source

#!/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:])