معرفی شرکت ها


clifun-0.0.2


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Construct a comand line interface based on a function or class
ویژگی مقدار
سیستم عامل -
نام فایل clifun-0.0.2
نام clifun
نسخه کتابخانه 0.0.2
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Tom Dimiduk
ایمیل نویسنده tom@dimiduk.net
آدرس صفحه اصلی -
آدرس اینترنتی https://pypi.org/project/clifun/
مجوز MIT
# clifun Because cli's should be fun(ctions) ;). ``` import clifun def my_program(a: int, b: str = "not provided"): print(f"Running some code with: a={a}, b={b}") if __name__ == "__main__": clifun.call(my_program) ``` That's all it takes. Clifun will inspect your function and collect the values it needs it from command line arguments, environment variables, or config files, and then call it. ``` python examples/function --a 1 ``` ``` Running some code with: a=1, b=not provided ``` You can even run functions in any module without modifying the module at all ``` python clifun.py examples/module.py my_program --a 1 ``` if you have the code checked out. Or if you pip installed ``` python -m clifun some_module.py function ... ``` Or if you have environment variables defined ``` export A=1 export B=hi python example.py ``` again yields without you having to provide values ``` Basic(a=1, b='hi') ``` `clifun` also supports nested objects (or functions taking complex objects as inputs) ``` from typing import Optional import datetime as dt import attr import clifun @attr.s(auto_attribs=True, frozen=True) class Foo: a: dt.datetime b: Optional[str] = None @attr.s(auto_attribs=True, frozen=True) class Bar: f: Foo c: int def my_program(f: Foo, c: int): print(Bar(f, c)) if __name__ == "__main__": bar = clifun.call(my_program) ``` You specify values for the fields in the nested class by referring to them with a their field name in the outer class ``` python examples/advanced.py --c 1 --f.a 2020-01-01 --f.b hi ``` ``` Bar(f=Foo(a=datetime.datetime(2021, 1, 1, 0, 0), b='hi'), c=1) ``` You can also supply one or more `json` formatted `config` files. Provide the name(s) of these files as positional arguments. `clifun` will search them, last file first, for any keys fields that are not provided at the command line before searching the environment. ``` python examples/advanced.py --c 1 examples/foo.json ``` ``` Bar(f=Foo(a=datetime.datetime(2021, 1, 1, 0, 0), b='str'), c=1) ``` `clifun` is inspired by [clout](https://github.com/python-clout/clout), but I wanted to try being a bit more opinionated to make both the library and code using it simpler.


زبان مورد نیاز

مقدار نام
>=3.6.2,<4.0 Python


نحوه نصب


نصب پکیج whl clifun-0.0.2:

    pip install clifun-0.0.2.whl


نصب پکیج tar.gz clifun-0.0.2:

    pip install clifun-0.0.2.tar.gz