Making argument parsing easy
Project description
A project designed to make command line argument parsing easy.
It is used as follows:
import easyargs
@easyargs
def main(name, count=1, greeting='Hello'):
"""A simple greeting program"""
for i in range(count):
print '{greeting} {name}!'.format(greeting=greeting, name=name)
if __name__ == '__main__':
main()
In this (rather contrived) example, main will be inspected and the arg keywords will be turned into positional arguments and the kwarg keywords will be turned into optional arguments. This can be seen if we run the above script with the help flag:
$ python simple.py -h
usage: simple_test.py [-h] [--count COUNT] [--greeting GREETING] name
A simple greeting program
positional arguments:
name
optional arguments:
-h, --help show this help message and exit
--count COUNT
--greeting GREETING
Note are that program description is automatically created based on the docstring of the function. Also note that the type of the default value is inspected so that the value of count is coerced to an integer:
$ python simple.py World
Hello World
$ python simple.py everybody --count 2 --greeting Hola
Hola everybody!
Hola everybody!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for easyargs-0.8.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39f8ee3114b9b62f7e33b430e20cb0c0d5a6bcccaf8a67499b62f5a0220ae4ea |
|
MD5 | 98d4a7a9b0cccb86a10dbc96ab07dc36 |
|
BLAKE2b-256 | 5445977d00e7d3c8f1777780c3bd08c6f1487f7a160312a6f4322c843fa1070d |