arger-1.4.8
توضیحات
Create argparser automatically from functions
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | arger-1.4.8 |
| نام | arger |
| نسخه کتابخانه | 1.4.8 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Noortheen Raja <jnoortheen@gmail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/arger/ |
| مجوز | MIT |
# Overview
A wrapper around argparser to help build CLIs from functions. Uses type-hints extensively :snake:.
[](https://pypi.python.org/pypi/arger)
[](https://pypi.org/project/arger/)



[](https://pypi.org/project/arger)
# Setup
## :gear: Installation
Install it directly into an activated virtual environment:
``` text
$ pip install arger
```
# :books: Usage
* create a python file called test.py
``` python
from arger import Arger
def main(param1: int, param2: str, kw1=None, kw2=False):
"""Example function with types documented in the docstring.
Args:
param1: The first parameter.
param2: The second parameter.
kw1: this is optional parameter.
kw2: this is boolean. setting flag sets True.
"""
print(locals())
arger = Arger(
main,
prog="pytest", # for testing purpose. otherwise not required
)
if __name__ == "__main__":
arger.run()
```
* Here Arger is just a subclass of `ArgumentParser`. It will not conceal you from using other `argparse` libraries.
* run this normally with
```sh
$ python test.py -h
usage: pytest [-h] [-k KW1] [-w] param1 param2
Example function with types documented in the docstring.
positional arguments:
param1 The first parameter.
param2 The second parameter.
optional arguments:
-h, --help show this help message and exit
-k KW1, --kw1 KW1 this is optional parameter. (default: None)
-w, --kw2 this is boolean. setting flag sets True. (default: False)
```
``` sh
$ python test.py 100 param2
{'param1': 100, 'param2': 'param2', 'kw1': None, 'kw2': False}
```
* Checkout [examples](docs/examples) folder and documentation to see more of `arger` in action. It supports any level of sub-commands.
# Features
- Uses docstring to parse help comment for arguments. Supports
+ [google](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
+ [numpy](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html#example-numpy)
+ [rst](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html)
- Flags will be generated from parameter-name.
1. e.g. `def main(param: ...)` -> `-p, --param`
2. If needed you could declare it inside docstring like `:param arg1: -a --arg this is the document`.
- one can use `Argument` class to pass any values to the
[parser.add_argument](https://docs.python.org/3/library/argparse.html#the-add-argument-method) function
- The decorated functions can be composed to form nested sub-commands of any level.
- Most of the Standard types [supported](./tests/test_args_opts/test_arguments.py).
Please see [examples](./docs/examples/4-supported-types/src.py) for more supported types with examples.
> **_NOTE_**
> - `*args` supported but no `**kwargs` support yet.
> - all optional arguments that start with underscore is not passed to `Parser`.
> They are considered private to the function implementation.
> Some parameter names with special meaning
> - `_namespace_` -> to get the output from the `ArgumentParser.parse_args()`
> - `_arger_` -> to get the parser instance
# Argparser enhancements
* web-ui : https://github.com/nirizr/argparseweb
* extra actions : https://github.com/kadimisetty/action-hero
* automatic shell completions using [argcomplete](https://github.com/kislyuk/argcomplete)
نیازمندی
| مقدار | نام |
|---|---|
| - | typing-extensions>3.7.4 |
| xtr | ipython; |
| xtr | tox; |
| xtr | jupyter; |
| xtr | better-exceptions; |
| xtr | git-changelog; |
| xtr | mkdocs; |
| xtr | mkdocs-material; |
| xtr | mkdocstrings; |
| xtr | pytkdocs; |
| xtr | mknotebooks; |
| xtr | pymdown-extensions; |
| xtr | pygments; |
| xtr | pydocstyle; |
| xtr | pylint>=2.11; |
| xtr | pytest; |
| xtr | pytest-cov; |
| xtr | pytest-describe; |
| xtr | pytest-expecter; |
| xtr | pytest-random; |
| xtr | freezegun; |
| xtr | pytest-lazy-fixture; |
| xtr | nbformat; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<4.0 | Python |
نحوه نصب
نصب پکیج whl arger-1.4.8:
pip install arger-1.4.8.whl
نصب پکیج tar.gz arger-1.4.8:
pip install arger-1.4.8.tar.gz