Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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


Release history Release notifications

Download files

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

Files for Cmdopt, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size Cmdopt-0.2.0-py2.4.egg (7.1 kB) File type Egg Python version 2.4 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0-py2.5.egg (7.0 kB) File type Egg Python version 2.5 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0-py2.6.egg (7.0 kB) File type Egg Python version 2.6 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0-py2.7.egg (7.0 kB) File type Egg Python version 2.7 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0-py3.0.egg (7.0 kB) File type Egg Python version 3.0 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0-py3.1.egg (7.0 kB) File type Egg Python version 3.1 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0-py3.2.egg (7.0 kB) File type Egg Python version 3.2 Upload date Hashes View hashes
Filename, size Cmdopt-0.2.0.tar.gz (9.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page