Skip to main content

A library to manage command line interface for an application.

Project description

A library to manage command line interface for an application.

Supported platforms

  • python 2.7 or python 3.x

  • Linux

Features

  • Decorator as well as subclassing based command addition.

  • Custom help text formatter which improves upon the rather sucky default formatter.

  • Automatic help text extraction from doc string.

Usage

A simple case of just the main command (without any subcommands):

@maincmd
def main(self, a, b):
        '''Add two numbers.
        a:      first number
        b:      second number

        This is where extra help text goes.
        It can be more than one line.'''

        try:
                print('sum: %d'%(int(a) + int(b)))
        except ValueError:
                print('bad integer')
                raise CommandError()

cmdline = CommandLine()
try:
        cmdline.execute()
except CommandLineError as e:
        print(e)

See examples directory in code for decorator and subclass based command handling.

Download

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

redcmd-1.0.0.tar.gz (10.4 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