Class based argument parser
Project description
Class-Argparse
Class based argument parser to simplify writing CLIs that have lots of options
How to use
from typing import Literal
from class_argparse import ClassArgParser
class Main(ClassArgParser):
"""
# ClassArgParser
example description
"""
def __init__(self) -> None:
super().__init__(name="Class ArgParser")
def no_args(self):
print("no_args")
def no_args_with_desc(self):
"""
some desc text goes here
second line of desc
"""
print("no_args_with_desc")
def some_args(self, arg: str):
print("some_args", arg)
def default_values(self, arg: str, default: int = 0):
print("default_values", arg, default)
def list_values(self, values: list[str]):
print("list_values", values)
def untyped_arg(self, untyped):
print("untyped_arg", untyped)
async def async_func(self, arg: str):
print("async_func", arg)
def literal_options(self, arg: Literal["a", "b"]):
print("literal_options", arg)
if __name__ == "__main__":
Main()()
How this works
- The class
ClassArgParserextendsArgumentParser - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file class_argparse-0.1.4.tar.gz.
File metadata
- Download URL: class_argparse-0.1.4.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
714a99880b188133e1023d78e5a95e4b6391b1d9253a179f0e4c94c4fa82610a
|
|
| MD5 |
0b11a86905c6e4a20ed17f1fa2c766a7
|
|
| BLAKE2b-256 |
f847c0ee0960f0172a6830da300a818921ea59d41ccab8507539c0a54a617fe2
|
Provenance
The following attestation bundles were made for class_argparse-0.1.4.tar.gz:
Publisher:
release.yml on neblar/class-argparse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
class_argparse-0.1.4.tar.gz -
Subject digest:
714a99880b188133e1023d78e5a95e4b6391b1d9253a179f0e4c94c4fa82610a - Sigstore transparency entry: 543067193
- Sigstore integration time:
-
Permalink:
neblar/class-argparse@54481fd9e6f5eb33c5c73c99264e28da27899b18 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/neblar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@54481fd9e6f5eb33c5c73c99264e28da27899b18 -
Trigger Event:
release
-
Statement type:
File details
Details for the file class_argparse-0.1.4-py3-none-any.whl.
File metadata
- Download URL: class_argparse-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed89b63fbf761f6ef8d8c77b00c2705b1457c6044946cc676d766f3995253a65
|
|
| MD5 |
597ee94cf7b68243d65f1e83a341449d
|
|
| BLAKE2b-256 |
532c1ebeeeb8f2a6da1889d1c2dae87c10b66dc4e3ae6622dd8b672eda0498d7
|
Provenance
The following attestation bundles were made for class_argparse-0.1.4-py3-none-any.whl:
Publisher:
release.yml on neblar/class-argparse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
class_argparse-0.1.4-py3-none-any.whl -
Subject digest:
ed89b63fbf761f6ef8d8c77b00c2705b1457c6044946cc676d766f3995253a65 - Sigstore transparency entry: 543067196
- Sigstore integration time:
-
Permalink:
neblar/class-argparse@54481fd9e6f5eb33c5c73c99264e28da27899b18 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/neblar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@54481fd9e6f5eb33c5c73c99264e28da27899b18 -
Trigger Event:
release
-
Statement type: