A command line parser for CVS-like commands, integrated with optparse
Python
Switch branches/tags
Nothing to show
Pull request Compare This branch is 9 commits behind pteichman:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmdparse
tests
.gitignore
COPYING
README
ez_setup.py
setup.py

README

cmdparse is a command line parser that works with CVS style
commands.  Each command can have its own optparse settings.

Install it with the usual setuptools usage:

$ python setup.py install

Example usage:

import cmdparse

class EchoCommand(cmdparse.Command):
    def __init__(self):
        cmdparse.Command.__init__(self, "echo", summary="echo a string")

        self.add_option("-c", "--count", type="int",
                        default="1", help="number of times to echo")

    def run(self, options, args):
        for i in xrange(options.count):
            print " ".join(args)

parser = cmdparse.CommandParser()
parser.add_command(EchoCommand())

(command, options, args) = parser.parse_args()
command.run(options, args)