{"id":16337966,"url":"https://github.com/jnoortheen/arger","last_synced_at":"2025-03-20T23:31:00.441Z","repository":{"id":44766450,"uuid":"247519447","full_name":"jnoortheen/arger","owner":"jnoortheen","description":"Create argparser automatically from py3.9+ annotations :snake:.","archived":false,"fork":false,"pushed_at":"2025-02-10T19:12:25.000Z","size":1070,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T08:07:31.847Z","etag":null,"topics":["argparse","argparser","cli","docstrings","typehints"],"latest_commit_sha":null,"homepage":"https://jnoortheen.github.io/arger/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jnoortheen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-15T17:47:50.000Z","updated_at":"2025-02-10T19:12:28.000Z","dependencies_parsed_at":"2022-09-19T06:50:45.210Z","dependency_job_id":null,"html_url":"https://github.com/jnoortheen/arger","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Farger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Farger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Farger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnoortheen%2Farger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jnoortheen","download_url":"https://codeload.github.com/jnoortheen/arger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244710564,"owners_count":20497262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argparse","argparser","cli","docstrings","typehints"],"created_at":"2024-10-10T23:48:41.400Z","updated_at":"2025-03-20T23:31:00.147Z","avatar_url":"https://github.com/jnoortheen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nA wrapper around argparser to help build CLIs from functions. Uses type-hints extensively :snake:.\n\n[![PyPi Version](https://img.shields.io/pypi/v/arger.svg?style=flat)](https://pypi.python.org/pypi/arger)\n[![Python Version](https://img.shields.io/pypi/pyversions/arger.svg)](https://pypi.org/project/arger/)\n![](https://github.com/jnoortheen/arger/workflows/test-and-publish/badge.svg)\n![](https://github.com/jnoortheen/arger/workflows/codeql-analysis/badge.svg)\n![](https://img.shields.io/badge/dynamic/json?label=coverage\u0026query=%24.coverage.status\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fjnoortheen%2Farger%2Fshields%2Fshields.json)\n[![PyPI License](https://img.shields.io/pypi/l/arger.svg)](https://pypi.org/project/arger)\n\n# Setup\n\n## :gear: Installation\n\nInstall it directly into an activated virtual environment:\n\n``` text\n$ pip install arger\n```\n\n# :books: Usage\n\n* create a python file called test.py\n\n``` python\nfrom arger import Arger\n\n\ndef main(param1: int, param2: str, kw1=None, kw2=False):\n    \"\"\"Example function with types documented in the docstring.\n    \n    Args:\n        param1: The first parameter.\n        param2: The second parameter.\n        kw1: this is optional parameter.\n        kw2: this is boolean. setting flag sets True.\n    \"\"\"\n    print(locals())\n\n\narger = Arger(\n    main,\n    prog=\"pytest\",  # for testing purpose. otherwise not required\n)\n\nif __name__ == \"__main__\":\n    arger.run()\n```\n\n* Here Arger is just a subclass of `ArgumentParser`. It will not conceal you from using other `argparse` libraries.\n\n* run this normally with\n\n```sh\n$ python test.py -h\nusage: pytest [-h] [-k KW1] [-w] param1 param2\n\nExample function with types documented in the docstring.\n\npositional arguments:\n  param1             The first parameter.\n  param2             The second parameter.\n\noptional arguments:\n  -h, --help         show this help message and exit\n  -k KW1, --kw1 KW1  this is optional parameter. (default: None)\n  -w, --kw2          this is boolean. setting flag sets True. (default: False)\n```\n\n``` sh\n$ python test.py 100 param2\n{'param1': 100, 'param2': 'param2', 'kw1': None, 'kw2': False}\n```\n\n* Checkout [examples](docs/examples) folder and documentation to see more of `arger` in action. It supports any level of sub-commands.\n\n# Features\n\n- Uses docstring to parse help comment for arguments. Supports\n    + [google](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)\n    + [numpy](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html#example-numpy)\n    + [rst](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html)\n- Flags will be generated from parameter-name.\n  1.  e.g. `def main(param: ...)` -\u003e `-p, --param`\n  2.  If needed you could declare it inside docstring like `:param arg1: -a --arg this is the document`. \n- one can use `Argument` class to pass any values to the \n  [parser.add_argument](https://docs.python.org/3/library/argparse.html#the-add-argument-method) function\n- The decorated functions can be composed to form nested sub-commands of any level.\n  \n- Most of the Standard types [supported](./tests/test_args_opts/test_arguments.py). \n  Please see [examples](./docs/examples/4-supported-types/src.py) for more supported types with examples.\n\n\u003e **_NOTE_** \n\u003e  - `*args` supported but no `**kwargs` support yet.\n\u003e  - all optional arguments that start with underscore is not passed to `Parser`. \n\u003e    They are considered private to the function implementation.\n\u003e    Some parameter names with special meaning\n\u003e      - `_namespace_` -\u003e to get the output from the `ArgumentParser.parse_args()`\n\u003e      - `_arger_` -\u003e to get the parser instance\n\n# Argparser enhancements\n\n* web-ui : https://github.com/nirizr/argparseweb\n* extra actions : https://github.com/kadimisetty/action-hero\n* automatic shell completions using [argcomplete](https://github.com/kislyuk/argcomplete)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnoortheen%2Farger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjnoortheen%2Farger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnoortheen%2Farger/lists"}