Simpler command line argument parsing
In the spirit of `optimist <https://github.com/substack/node-optimist>`__: less magic, more flexibility.
pi install argv
Quickstart
Manual specification of arguments, no configuration:
import argv
argv.parse(['-i', 'input.txt', '-z', '--verbose'])
>>> {'i': 'input.txt', 'verbose': True, 'z': True}
Uses sys.argv (without the executable name) if no argument list is given:
import sys
sys.argv
>>> ['/usr/local/bin/bottler', 'exec', 'prog.py', '--debug']
argv.parse()
>>> {'_': ['exec', 'prog.py'], 'debug': True}
Configuration:
parser = argv.Parser()
parser.add('action')
parser.add('target')
parser.add('-d', '--debug')
parser.parse(['exec', 'prog.py', '--debug'])
>>> {'action': 'exec', 'd': True, 'debug': True, 'target': 'prog.py'}
Testing
Continuous integration:
Or run tests locally:
python setup.py test
Development
Terminology:
flag: a command line argument marked with a double dash or each component of a group denoted by a single dash. E.g.,
--verbose --logfile logs/app.txt has two flags: verbose and logfile.
-czf archive.tgz app/ has three flags: c, z, and f.
token: a white-space separated command line item. E.g.,
`–input= –logfile logs/app.txt
License
Copyright (c) 2013 Christopher Brown. MIT Licensed.
Metadata
Release files for argv 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| argv-0.0.3.tar.gz | 6.8 kB | Without provenance | Details for argv-0.0.3.tar.gz |
Release files / argv-0.0.3.tar.gz
| Download URL | argv-0.0.3.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce8e08d227758f38704954269d37b0002d45c0e9f2394048f66c76cc4cae498a
|
|
BLAKE2b-256 checksum How to use checksums |
eade35b617e02843d7b5d7fe462a9c7823c8d55dab72f91526e5d25da49fac9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for argv 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.