{ "info": { "author": "Harald Sorenson", "author_email": "haraldesorenson@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# CLIEP Python Console Entrypoint Library\n\nCLIEP (CLI Entrypoint) is a small, no dependency system to streamline interfacing with TTYs and consoles, using a primary entrypoint function via decorators with optional automatic argument parsing.\n\n## Installation:\n```pip3 install cliep```\n\nIt is recommended you use a virtualenv for individual project's dependencies.\nYou can also add cliep to your requirements.txt for larger projects.\n\n## Documentation:\nThe `cliep` namespace contains two important elements: `entrypoint`, and `Argument`.\n\n```\nentrypoint:\n\targ_map - the list of arguments to parse and send to the entrypoint.\n\thelp_func - function to handle printing the help page on err/trigger. Uses builtin help generator by default.\n\thelp_trigger - The flag to trigger help off of, defaults to '-h'. NOTE: this overrides any arguments that share the same name.\n```\n\nEntrypoints are also required to type hint that they return either `int` or `None`, otherwise\nthe entrypoint will not be allowed to run.\n\n```\nArgument:\n\tshortname: str - Required, specifies the shorthand command name ('-a', '-b', etc).\n\tlongname: str - Optional, allows for a second proper command name ('--append').\n\tis_flag: bool - Specifies whether or not the argument is expecting a value, defaults False.\n\tis_required: bool - Specifies whether or not this argument must be found, defaults False.\n\tdefault: any - Specifies a default value for optional arguments that are not supplied.\n```\n\nThese two elements make up the entirety of the use case CLIEP hopes to solve.\nThis allows for auto-parsing of arguments and feeding them into the specified entrypoint.\n\nAn important note: When using Arguments the values of each Argument are passed into\nthe entrypoint in the order they are added. e.g. arguments `a, b, c` will be sent to\nthe entrypoint as `a, b, c`. Furthermore, arguments use the type hinting of the entrypoints\nparameters to typecast before sending. So type hints are required for custom argument parsing.\n\nAn example of this is as follows:\n\n```python\n@entrypoint([Argument('-a')])\ndef main(a: int) -> int:\n\treturn a\n```\n\nThis example will only work as long as the `a` parameter is type hinted.\n\nThis extensive use of type hinting is present in order to remove a guessing game of what\nis being passed back and forth, and to lower possible points of failure.\n\nIf bad data is supplied to a type casted argument (e.g. `str` -> `int`), then the value\nwill be set to `None`, and forwarded to the entrypoint. If the argument that failed to be \ncoerced is a required field, the help message will be displayed to the user. This is so that\nthe proper entrypoint can handle informing the user of bad (or no) input, or manually setting a\ndefault value. Although this may not be the most elegant solution, this allows for proper\nerror handling in cases where the type cast is wanted or required.\n\nIf a type hint in the entrypoint is `list` or `dict` (or the generic counterparts), \nCLIEP will raise a `NotImplementedError` due to complications with Pythons preprocessing\nor argv.\n\nIn cases where you want to override the default help output, `help_func` should expect:\n\n```\nerror: str = Error text in case of missing required field.\nargs: List[Argument] - The list of argument objects.\ntrigger: str - The trigger phrase that is used to trigger the help screen.\n```\n\n## Examples:\nIn it's most basic form, an entrypoint looks like this:\n\n```python\nfrom cliep import entrypoint\n\n@entrypoint\ndef main(argv, argc) -> int:\n return 0\n```\n\nYou see without custom argument parsing, the entrypoint will just forward the argv and len(argv) to the entrypoint.\nAnother important thing to notice is the use of type hinting. CLIEP uses type hinting to enforce returns to the TTY.\nAs such, an entrypoint function must either type hint a return of type \"int\" or type \"None\".\n\nA more complicated example could look like this:\n\n```python\nfrom cliep import entrypoint, Argument\n\n@entrypoint([\n Argument('-f', '--flag', is_flag=True),\n Argument('-i', '--input', is_required=True),\n])\ndef main(flag: bool, user_input: int) -> int:\n print(flag, user_input)\n return user_input or 0\n```\n\nIn this example we further the use of type hinting, as the Arguments in the list are passed\nto the entrypoint function in order of their place in the list, and as the values of each\nArgument are gathered, they use the type hints in the main function declaration to know what\nto type cast too. Because of this, in an entrypoint function all arguments must have a type\nhint.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hsorenson/cliep", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "cliep", "package_url": "https://pypi.org/project/cliep/", "platform": "", "project_url": "https://pypi.org/project/cliep/", "project_urls": { "Homepage": "https://github.com/hsorenson/cliep" }, "release_url": "https://pypi.org/project/cliep/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Simple CLI entrypoint and argument parsing.", "version": "1.0.3" }, "last_serial": 4936688, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3c79deafb0064851f21bf285bfbe3238", "sha256": "2582d269b6e18f29c5503b3c6a5ee4c1d5dc9a4063a27a1540cce504db74b336" }, "downloads": -1, "filename": "cliep-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3c79deafb0064851f21bf285bfbe3238", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15813, "upload_time": "2019-03-06T01:30:10", "url": "https://files.pythonhosted.org/packages/72/c0/ae8842a1cdb900a4885e8c15218e4d9a8657c16a586324ea1afaf8dcdb9e/cliep-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0cabd4b65496fd656d45f0b9a561a5c8", "sha256": "30714bda414ffb6c5fa704e50d921494619125682c98aade7cce33d9b7e9bbeb" }, "downloads": -1, "filename": "cliep-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0cabd4b65496fd656d45f0b9a561a5c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2753, "upload_time": "2019-03-06T01:30:12", "url": "https://files.pythonhosted.org/packages/25/63/691b8fa244c455801a49d017e7ac5b985ea2e39bd5e3f7b22d65b5e01616/cliep-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "60f1598ebf53cb549030abe6ea9c228d", "sha256": "c3a48434a687947d7683bc7964a5874b24fd9cbeee89cb8622112b9f19a1adc3" }, "downloads": -1, "filename": "cliep-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "60f1598ebf53cb549030abe6ea9c228d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17522, "upload_time": "2019-03-06T04:45:36", "url": "https://files.pythonhosted.org/packages/49/4f/59d3a818f06afd76818de31c2a96b3b80f1f3960e64c3168167ce37c5fba/cliep-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ca77c8a8cda7a75be45e09fdfc9152fa", "sha256": "dc62cbbc462a6cba16382e98dab786a1f0ee7b6d1711b90ba1e62da227621274" }, "downloads": -1, "filename": "cliep-1.0.1.tar.gz", "has_sig": false, "md5_digest": "ca77c8a8cda7a75be45e09fdfc9152fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4770, "upload_time": "2019-03-06T04:45:38", "url": "https://files.pythonhosted.org/packages/af/10/a40227978b1e3e7545565df39ce7506410d8a41206de5ee68c0ed1b1860b/cliep-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "c57d0524fd9d6633b86bbfd3256ab76d", "sha256": "a238a18d8363b6ea7e8b5af25c3443ff5fd78dca67d870c4bb22e4d5393585bb" }, "downloads": -1, "filename": "cliep-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c57d0524fd9d6633b86bbfd3256ab76d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17649, "upload_time": "2019-03-07T01:18:34", "url": "https://files.pythonhosted.org/packages/13/be/a60d0eaab9fbd96f752f1a4002c59b340ca7461dfc470b82f58d84e1023e/cliep-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b85d63c9ccba9ffaa6bbe17666d1c985", "sha256": "cbba5c4988308f2549d65db9c8d63b4e3abcb17973c5ef1bb52911a60c511409" }, "downloads": -1, "filename": "cliep-1.0.2.tar.gz", "has_sig": false, "md5_digest": "b85d63c9ccba9ffaa6bbe17666d1c985", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4893, "upload_time": "2019-03-07T01:18:36", "url": "https://files.pythonhosted.org/packages/2a/8e/cea371233e06caf9d1a777013c42b5f74fe28380ae049285fe6cf8c66b47/cliep-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "2bbd915d1f0efa50a123dce562a3690b", "sha256": "13f8fa4c50ee07ba2f79088e6a9e70febab03fd2701522e904b055e54e7b6079" }, "downloads": -1, "filename": "cliep-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "2bbd915d1f0efa50a123dce562a3690b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17650, "upload_time": "2019-03-13T22:20:57", "url": "https://files.pythonhosted.org/packages/99/43/9c39d61856e98d781fcdd24e61efea0a41eaf5f2b43f25c91216b1b1dc4a/cliep-1.0.3-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2bbd915d1f0efa50a123dce562a3690b", "sha256": "13f8fa4c50ee07ba2f79088e6a9e70febab03fd2701522e904b055e54e7b6079" }, "downloads": -1, "filename": "cliep-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "2bbd915d1f0efa50a123dce562a3690b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17650, "upload_time": "2019-03-13T22:20:57", "url": "https://files.pythonhosted.org/packages/99/43/9c39d61856e98d781fcdd24e61efea0a41eaf5f2b43f25c91216b1b1dc4a/cliep-1.0.3-py3-none-any.whl" } ] }