Class based argument parser
Project description
Class-Argparse
Class based argument parser to simplify writing CLIs that have lots of options
How to use
class Main(ClassArgParser):
def __init__(self) -> None:
super().__init__(name="Class ArgParser")
async def foo(self, first: str):
print(f"foo, first={first}")
def bar(self):
print("bar")
async def baz(self, first: str, second: int):
print(f"baz, first={first}, second={second}")
if __name__ == "__main__":
Main()()
How this works
- The class
ClassArgParser
extendsArgumentParser
- The initialization function finds add adds all the methods on child classes that are public i.e. their names don't start with
__
- The object of the class is called and after identifying whether the function being called it is async or sync it runs the function accordingly
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
class-argparse-0.1.1.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for class_argparse-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b050d7fbddef55f89bc60d2d3030b60758aa7be8068cb5d76aa144b92618019a |
|
MD5 | fd5320374160dd71127cee7fea25b2c9 |
|
BLAKE2b-256 | 77c76d9f5c5de550799ae39f0a94190ed61444bf53da6204f26a9ee9cde37379 |