Skip to main content

CLI sub-command library

Project description

This is a tiny library to help you write CLI applications with many sub-commands.

Installation

pip install subc

Use

Create your own command subclass for your application (optional, but encouraged):

class MyCmd(subc.Command):
    pass

Then, write commands in your application which sub-class this:

class HelloWorld(MyCmd):
    name = 'hello-world'
    description = 'say hello'
    def run(self):
        print('hello world')

Finally, use your application-level subclass for creating the argument parser and running your application:

def main():
    parser = argparse.ArgumentParser(description='a cool tool')
    MyCmd.add_commands(parser)
    args = parser.parse_args()
    args.func(args)

License

This project is released under the Revised BSD license. See LICENSE.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subc-0.1.0.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

subc-0.1.0-py2.py3-none-any.whl (2.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page