Skip to main content

A command line shell framework

Project description

This module combines the Python standard library modules argparse and cmd to provided a unified way to make cli programs that can also be interactive when invoked in “shell” mode.

The main benefit to using this package is streamlined command hierarchy when you want to have rich set of subcommands along with a pretty powerful tab completion layer that parses argparse arguments automagically.

Requirements

  • None more black!

Installation

python3 ./setup.py build
python3 ./setup.py install

Compatibility

  • Python 3.4+

TODO

  • Documentation

  • Documentation

  • Documentation

Getting Started

TBD

Examples

Hello World

A requisite Hello World..

import shellish


class Hello(shellish.Command):
    """ I am a required docstring used to document the --help output! """

    name = 'hello'

    def __init__(self, *args, **kwargs):
        self.add_subcommand(World, default=True)

    def run(self, args):
        shellish.Shell(self).cmdloop()


class World(shellish.Command):
    """ Say something. """

    name = 'world'

    def run(self, args):
        print('Hello World')


if __name__ == '__main__':
    root = Hello()
    args = root.argparser.parse_args()
    try:
        root.invoke(args)
    except KeyboardInterrupt:
        sys.exit(1)
python3 ./hello.py hello world

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

shellish-0.0.2.tar.gz (9.5 kB view hashes)

Uploaded Source

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