typed command line argument parser
Project description
typed-cap
Cap is a python Command-line Argument Parser that provides typing support. Using Cap requires less code to generate a more easy to use parser.
Usage
⚠️ typed_cap
required python>=3.9
pip install typed_cap
Quick Example
from typed_cap import Cap
class Args:
"""description here"""
# @alias=c
config: str | None
"""file path to config file"""
# @alias=d
depth: int
"""depth of search"""
dry_run: bool = True
"""run without making any changes"""
cap = Cap(Args)
parsed = cap.parse()
print(parsed.args.__dict__)
print(parsed.argv)
python demo.py
# Cap.parse: option depth:int is required but it is missing
# ArgsParserMissingArgument
python demo.py --help
# description here
#
# OPTIONS:
# -c,--config file path to config file
# -d,--depth depth of search
# --dry_run run without making any changes (default: True)
# -h,--help display the help text
python demo.py -d 5 hello typed cap
# {'depth': 5, 'config': None, 'dry_run': True}
# ['hello', 'typed', 'cap']
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
typed_cap-0.3.0.tar.gz
(524.8 kB
view hashes)
Built Distribution
typed_cap-0.3.0-py3-none-any.whl
(28.4 kB
view hashes)
Close
Hashes for typed_cap-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70bd049e2c685f216afd05fa471b36fd707546ebd00b0804fc235e811d9577fe |
|
MD5 | 37fcf805c68ba0133d4f176a9398f275 |
|
BLAKE2b-256 | ad1ddf9fe1c73c6d26ac900dac15c04a05ad1b51ee7d3acda69047f19e5f3ff0 |