A simple wrapper around argparse to permit declarative construction and argument retrieval.
Project description
Declarative Argparse
This project introduces a wrapper argound the built-in argparse
module that permits one to make a declarative parser for options.
[[TOC]]
Example
import argparse
from declarative_argparse import DeclarativeOptionParser
from declarative_argparse.options.int import IntDO
from declarative_argparse.options.str import StrDO
class DAPExample(DeclarativeOptionParser):
def __init__(self) -> None:
super().__init__(argp=argparse.ArgumentParser())
self.x: IntDO = self.addInt('--x', '-x', description='X coordinate')
self.y: IntDO = self.addInt('--y', '-y', description='Y coordinate')
self.name: StrDO = self.addStr('--name', description='Change tile name').setNArgs('?')
self.id: StrDO = self.addStr('id', description='specify tile ID')
# ...
args = DAPExample()
args.parseArguments(['--x=0', '-y', '1', 'abc1'])
assert args.x.get_value() == 0
assert args.y.get_value() == 1
assert args.name.get_value() is None
assert args.id.get_value() == 'abc1'
License
MIT
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
Built Distribution
Close
Hashes for declarative_argparse-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 964434ddfbfd0c9e5247b6ea27487accff719ab027a98ddfd62522589b466584 |
|
MD5 | d3bb4a77a15ff13cfb1f45b853fa3998 |
|
BLAKE2b-256 | a51e10db7229eb7e8f41b39a7b341c1e9c27a3b060faa9b1a416e23b86f351e7 |
Close
Hashes for declarative_argparse-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfeea063464a8adb5279ab4fb9511c111a801dd2fc3722b752ad020e99098aa6 |
|
MD5 | db64289f87c38474e9edc2b775f82037 |
|
BLAKE2b-256 | 54d4b7e05b636af9bd986e3ef225565eb5a08a43433767784e2771d45e9448b1 |