Parse environment variables and CLI arguments for a given function signature.
Project description
Argmagic
Automatically generate argparse based env-var/CLI-interface from a given function.
Example:
Given a function with a docstring and type hints.
def hello(name: str):
'''
Say hello to name.
Args:
name: Your name.
Raises:
Nothing.
Returns:
Nothing.
'''
print('Hello', name)
Create a CLI interface:
argmagic(hello)
Argmagic will call the function with all parameters filled from CLI arguments.
$ ./hello.py -h
usage: hello [-h] [--name NAME]
Say hello to name.
optional arguments:
-h, --help show this help message and exit
--name NAME Your name.
Additionally all specified parameters can also be defined via environment variables.
$ NAME=test hello.py
Hello test
These can then again be overriden by CLI arguments.
$ NAME=test hello.py --name something
Hello something
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
argmagic-0.0.1.tar.gz
(3.5 kB
view hashes)