Skip to main content

pretty good command-line option parser

Project description

Cmdopt.py is command-line option parser for Python.

Example:

import sys, cmdopt
## create parser
parser = cmdopt.Parser()
## define options
parser.option("-h, --help",       "show help")
parser.option("-f, --file=FILE",  "read file")
parser.option("-i, --indent=N",   "indent width")\
      .validation(lambda val: not val.isdigit() and "integer required.")\
      .action(lambda val, opts: setattr(opts, 'indent', int(val)))
## parse args
args = sys.argv[1:]
opts = parser.parse(args)    # may raise cmdopt.ParseError
if opts.help:
    print(parser.help())     # or parser.help(width=15, indent="  ")

Features:

  • Validator

  • Handler

  • Help message

  • Multiple option

See README 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

Cmdopt-0.2.0.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distributions

Cmdopt-0.2.0-py3.2.egg (7.0 kB view hashes)

Uploaded Source

Cmdopt-0.2.0-py3.1.egg (7.0 kB view hashes)

Uploaded Source

Cmdopt-0.2.0-py3.0.egg (7.0 kB view hashes)

Uploaded Source

Cmdopt-0.2.0-py2.7.egg (7.0 kB view hashes)

Uploaded Source

Cmdopt-0.2.0-py2.6.egg (7.0 kB view hashes)

Uploaded Source

Cmdopt-0.2.0-py2.5.egg (7.0 kB view hashes)

Uploaded Source

Cmdopt-0.2.0-py2.4.egg (7.1 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