{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "ancli\n=====\n\n.. image:: https://i.imgur.com/5hCKc9u.png\n :target: https://i.imgur.com/5hCKc9u.png\n :align: center\n\nBuilding argument parser from a function annotation. A simple utility inspired by\n``Fire`` and ``docopt``. Ad-hoc solution for someone who often writes scripts with a\nsingle entry point.\n\nHow?\n----\n\nThe process of building CLI with ``ancli`` is very simple.\n\n1. Write a plain Python function with annotated parameters.\n2. Wrap it with ``make_cli``.\n3. Run your script.\n\n\nExamples\n--------\n\n1. Function with annotated parameters\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe function ``run`` has explicitly annotated parameters and its signature is used\nto instantiate ``argparse.ArgumentParser`` instance that accepts parameters with\nspecific types and default (if any) parameters. If default value is not provided,\nthen the parameter is considered to be required.\n\n.. code:: python\n\n from ancli import make_cli\n\n def run(path: str, flag: bool = True, iterations: int = 1):\n print(f'run: path={path}, flag={flag}, iterations={iterations}')\n\n if __name__ == '__main__':\n make_cli(run)\n\nNow this snippet can be used as follows.\n\n.. code:: bash\n\n $ python script.py --path file.txt --flag 0\n run: path=file.txt, flag=False, iterations=1\n\n\n2. Function without annotations\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe functions without type annotations try to infer the parameters types based\non their default values.\n\n.. code:: python\n\n from ancli import make_cli\n\n def run(a, b=2, c=3.0):\n for param in (a, b, c):\n print(type(param))\n\n if __name__ == '__main__':\n make_cli(run)\n\nThe parameters without default values are considered as strings.\n\n.. code:: bash\n\n $ python script.py --a 1 --b 2 --c 3.0\n \n \n \n\n3. Running ``ancli`` as a module\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nRunning package as a module allows to dynamically build a CLI from some function. \nYou just need to specify a path to the module, and function which should be \ntreated as an entry point.\n\n.. code:: bash\n\n $ python -m ancli examples.functions:compute --a 2 --b 6\n 42\n\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "https://github.com/devforfu/ancli/archive/v0.1.3.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/devforfu/ancli", "keywords": "", "license": "", "maintainer": "devforfu", "maintainer_email": "", "name": "ancli", "package_url": "https://pypi.org/project/ancli/", "platform": "", "project_url": "https://pypi.org/project/ancli/", "project_urls": { "Download": "https://github.com/devforfu/ancli/archive/v0.1.3.tar.gz", "Homepage": "https://github.com/devforfu/ancli" }, "release_url": "https://pypi.org/project/ancli/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Small utility to convert functions into CLI", "version": "0.1.3" }, "last_serial": 5992022, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "44fae72a8b80eb5146c127aedf2ea85b", "sha256": "580f62b848024b572d6dcd34ae1630d3d27c160e9c768e7025dabc59c1b1bca9" }, "downloads": -1, "filename": "ancli-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "44fae72a8b80eb5146c127aedf2ea85b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4361, "upload_time": "2019-06-30T18:13:32", "url": "https://files.pythonhosted.org/packages/a3/cb/002307f2c001e4fc652241615ce72be236751cadbc4be91a0f446dcebfba/ancli-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0d6e5aec7d25f3d42ca0b3e5b93cad1b", "sha256": "9a39ae6ceadfe32577a9a81aa9334e50bffc9742f90e6dc59802cb125080cc40" }, "downloads": -1, "filename": "ancli-0.1.2.tar.gz", "has_sig": false, "md5_digest": "0d6e5aec7d25f3d42ca0b3e5b93cad1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3019, "upload_time": "2019-06-30T18:13:34", "url": "https://files.pythonhosted.org/packages/03/40/d34f4cd0b07be39513b9612de8009b71f3ccd7bc83019541e0826f7359b3/ancli-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "b657615f46c9096a9c4ee52532aa820e", "sha256": "ef3165fa9799d260c8131981ddf5b99786708d460c24c5ce1371f7d0c35267a2" }, "downloads": -1, "filename": "ancli-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b657615f46c9096a9c4ee52532aa820e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4638, "upload_time": "2019-10-17T19:45:31", "url": "https://files.pythonhosted.org/packages/df/a5/9e1e170ebfebfe50287fb74a473871122efa0a91b2b2d3feec0528e3fb2b/ancli-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "597ec5e20e8ae5fb16ed38b54f1f5eb5", "sha256": "2d7af39b313ba45a72618b304a8bd12c076f45786ced273ea6bdbcf8f9bf6585" }, "downloads": -1, "filename": "ancli-0.1.3.tar.gz", "has_sig": false, "md5_digest": "597ec5e20e8ae5fb16ed38b54f1f5eb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3246, "upload_time": "2019-10-17T19:45:34", "url": "https://files.pythonhosted.org/packages/c0/dc/7fde3ad1c2583c787b55da57c6cee38525c99f1ef76956c22d7e2d79139c/ancli-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b657615f46c9096a9c4ee52532aa820e", "sha256": "ef3165fa9799d260c8131981ddf5b99786708d460c24c5ce1371f7d0c35267a2" }, "downloads": -1, "filename": "ancli-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b657615f46c9096a9c4ee52532aa820e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4638, "upload_time": "2019-10-17T19:45:31", "url": "https://files.pythonhosted.org/packages/df/a5/9e1e170ebfebfe50287fb74a473871122efa0a91b2b2d3feec0528e3fb2b/ancli-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "597ec5e20e8ae5fb16ed38b54f1f5eb5", "sha256": "2d7af39b313ba45a72618b304a8bd12c076f45786ced273ea6bdbcf8f9bf6585" }, "downloads": -1, "filename": "ancli-0.1.3.tar.gz", "has_sig": false, "md5_digest": "597ec5e20e8ae5fb16ed38b54f1f5eb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3246, "upload_time": "2019-10-17T19:45:34", "url": "https://files.pythonhosted.org/packages/c0/dc/7fde3ad1c2583c787b55da57c6cee38525c99f1ef76956c22d7e2d79139c/ancli-0.1.3.tar.gz" } ] }