# Class-Argparse
Class based argument parser to simplify writing CLIs that have lots of options
## How to use
```python
from typing import Literal
class Main(ClassArgParser):
def __init__(self) -> None:
super().__init__(name="Class ArgParser")
def no_args(self):
print("no_args")
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
1. The class `ClassArgParser` extends `ArgumentParser`
2. The initialization function finds add adds all the methods on child classes that are public i.e. their names don't start with `__`
3. 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
Raw data
{
"_id": null,
"home_page": "https://github.com/neblar/class-argparse",
"name": "class-argparse",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Class Based,CLI,Argparse",
"author": "Neblar",
"author_email": "support@neblar.com",
"download_url": "https://files.pythonhosted.org/packages/60/05/b935fe18823f39f38c8c76b796e6281adf16aea213aff071c40a7deba274/class-argparse-0.1.3.tar.gz",
"platform": null,
"description": "# Class-Argparse\n\nClass based argument parser to simplify writing CLIs that have lots of options\n\n## How to use\n\n```python\nfrom typing import Literal\n\nclass Main(ClassArgParser):\n\n def __init__(self) -> None:\n super().__init__(name=\"Class ArgParser\")\n\n def no_args(self):\n print(\"no_args\")\n\n def some_args(self, arg: str):\n print(\"some_args\", arg)\n\n def default_values(self, arg: str, default: int = 0):\n print(\"default_values\", arg, default)\n\n def list_values(self, values: List[str]):\n print(\"list_values\", values)\n\n def untyped_arg(self, untyped):\n print(\"untyped_arg\", untyped)\n\n async def async_func(self, arg: str):\n print(\"async_func\", arg)\n\n def literal_options(self, arg: Literal[\"a\", \"b\"]):\n print(\"literal_options\", arg)\n\nif __name__ == \"__main__\":\n Main()()\n```\n\n## How this works\n\n1. The class `ClassArgParser` extends `ArgumentParser`\n2. The initialization function finds add adds all the methods on child classes that are public i.e. their names don't start with `__`\n3. 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\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Class based argument parser",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/neblar/class-argparse"
},
"split_keywords": [
"class based",
"cli",
"argparse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ae7fe33a9a9c3f184ccc8901d432380744c8c1d6ea8d2b0d2472314ed57e021",
"md5": "1714922fe8d14dba2c6ce7669c9e8870",
"sha256": "63c103fe7929be30878467b5e4903128297b63a5fc5bc6d6ecbc2b3b56b465c0"
},
"downloads": -1,
"filename": "class_argparse-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1714922fe8d14dba2c6ce7669c9e8870",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3902,
"upload_time": "2024-02-03T18:38:24",
"upload_time_iso_8601": "2024-02-03T18:38:24.494912Z",
"url": "https://files.pythonhosted.org/packages/7a/e7/fe33a9a9c3f184ccc8901d432380744c8c1d6ea8d2b0d2472314ed57e021/class_argparse-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6005b935fe18823f39f38c8c76b796e6281adf16aea213aff071c40a7deba274",
"md5": "1aeb23a50820cdd7026ecbe5f30253bb",
"sha256": "c51643f6e961177f5e9e010cf4ea0aeaa297b754751ef7681bf3cf1a0860c76d"
},
"downloads": -1,
"filename": "class-argparse-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "1aeb23a50820cdd7026ecbe5f30253bb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3430,
"upload_time": "2024-02-03T18:38:25",
"upload_time_iso_8601": "2024-02-03T18:38:25.802988Z",
"url": "https://files.pythonhosted.org/packages/60/05/b935fe18823f39f38c8c76b796e6281adf16aea213aff071c40a7deba274/class-argparse-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-03 18:38:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "neblar",
"github_project": "class-argparse",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "class-argparse"
}