A package designed to simplify configurable defaults from argparse.
Project description
cfg_argparser
a config wrapper I made to be easily applied to argparse objects.
Example
import argparse
from cfg_argparser import ConfigArgParser
def parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser()
parser.add_argument("--file")
return parser
if __name__ == "__main__":
args = ConfigArgParser(parser(),
"config.json",
exit_on_change=True).parse_args()
print(args.file)
Wrapping the ConfigArgParser
around parser()
adds a few "magic" arguments.
here's what it adds:
Config options:
--set KEY VAL change a default argument's options
--reset [VALUE ...] removes a changed option.
--reset_all resets every option.
Here's what it looks like in practice:
> python example.py
None
> python example.py --file foo.txt
foo.txt
> python example.py --set file foo.txt
> python example.py
foo.txt
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
cfg-argparser-1.0.5.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for cfg_argparser-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c9f78c5692406424d5199e0e50da62c151f35491369ffca3ea2e7a03d69760f |
|
MD5 | 1219ba2f9da7bd1334ab0b3861cc8e80 |
|
BLAKE2b-256 | 177e94cae4910e6bc0e845d078c2bb0c03719837d02208c4b82c95b050415592 |