Additional classes for argparse
Project description
Python argparse.ArgumentParser subclass(es)
Quick example of argparser declaration from dictionary:
import sys from argparse.extra import DictArgumentParser def run_testarg_processing(args, argv): print 'testarg argument used' ARGUMENTS = {'--use-something':{'dest':'use_something', 'action':'store_true', 'default':False}, 'sub:testarg':{ #sub:testarg will create subparser 'testarg' #depth of subargs is unlimited 'description':'Test arg subcommand', 'help':'Test help' 'func':run_testarg_processing, '--use-sub-something':{'dest':'use_sub_something', 'action':'store_true', 'default':False}, }} DEFAULTS_ONLY = ['func',] def get_argparser(argsdict=ARGUMENTS): #always create get_argparser function for your cli apps #this will enable easy integration of subsequent applications #with your argparser return DictArgumentParser(argsdict, DEFAULTS_ONLY) def main(args=sys.argv): args, argv = get_argparser().parse_known_args(args[1:]) args.func(args, argv) if __name__ == '__main__': main()
Installation
Try one of these:
python setup.py install easy_install argparse.extra pip install argparse.extra
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
argparse.extra-0.0.2.tar.gz
(122.2 kB
view details)
Built Distribution
File details
Details for the file argparse.extra-0.0.2.tar.gz
.
File metadata
- Download URL: argparse.extra-0.0.2.tar.gz
- Upload date:
- Size: 122.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca84a705caeac5cb5dd0246e03555ca71f2facd63da16954b620658dc18e836e |
|
MD5 | 9f3be642f12b5f1611e62e49dc513155 |
|
BLAKE2b-256 | 0c1e22b27ee1b049232f7571039603cf9f95016482430458cac9741a11a804c0 |
File details
Details for the file argparse.extra-0.0.2-py2.7.egg
.
File metadata
- Download URL: argparse.extra-0.0.2-py2.7.egg
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf3fea1b6025e904ca42a974e67181ea7478fceefc7e3b3b854591297e030902 |
|
MD5 | 158d7cf9402a58814aad6c6b5c5e1d00 |
|
BLAKE2b-256 | b17aabb4f767a4a590de54f4c12c251aea1bc209432c4d1e02876105d91b2a70 |