A library to manage command line interface for an application.
Project description
A simple library to handle command line of an application with support for subcommands, as well as, automatic help extraction from doc strings.
Supported platforms
python 2.7 / 3.x
Linux / Windows
Features
Decorator as well as subclass based command addition.
Custom help text formatter which improves upon the rather lousy default formatter.
Automatic help text extraction from doc strings.
Usage
A simple case of just the main command (without any subcommands):
from redcmd import maincmd, CommandLine, CommandLineError @maincmd def main(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. [https://github.com/amol9/redcmd/tree/master/examples]
Download
Project details
Release history Release notifications | RSS feed
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.1.3.tar.gz
(26.3 kB
view hashes)