{ "info": { "author": "Carvell Scott", "author_email": "carvell.scott@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development" ], "description": "# completion_utils\n\nA lightweight set of functions intended to make writing shell completion functions in python easier. Install with `pip install completion-utils` and import what you need from `completion_utils`. Generally you only need to import `bash_completion_decorator`, and decorate a function with it.\n\n## Usage\nSupposing you have some simple completion like this already...\n```\n#!/usr/bin/env python3\nimport sys\n\ndef foobar():\n return [\"a\", \"bunch\", \"of\", \"potential\", \"matches\"]\n\n\ndef completion_hook(cmd, curr_word, prev_word):\n potential_matches = foobar()\n matches = [k for k in potential_matches if k.startswith(curr_word)]\n return matches\n\n\ndef main():\n results = completion_hook(*sys.argv[1:])\n if len(results):\n print(\"\\n\".join(results))\n\n\nif __name__ == \"__main__\":\n main()\n```\n\nYou can then decorate `completion_hook` with `bash_completion_decorator` to have shell completion automatically supply the necessary arguments and use bash_complete to test out the results of potential completions.\n```\n#!/usr/bin/env python3\nimport sys\nimport unittest\nfrom completion_utils import bash_completion_decorator, bash_complete\n\nclass CompletionTestCase_up(unittest.TestCase):\n def test_all_options_show(self):\n expected = \"\\n\".join(sorted(foobar()))\n actual = bash_complete(\"heylook \", __file__)\n\n def test_one_option(self):\n expected = \"m\"\n actual = bash_complete(\"heylook m\", __file__)\n\ndef foobar():\n return [\"a\", \"bunch\", \"of\", \"potential\", \"matches\"]\n\n\n@bash_completion_decorator\ndef completion_hook(cmd, curr_word, prev_word):\n potential_matches = foobar()\n matches = [k for k in potential_matches if k.startswith(curr_word)]\n return matches\n\nif __name__ == \"__main__\":\n completion_hook()\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/CarvellScott/completion_utils", "keywords": "bash completion,complete,autocomplete,auto-complete", "license": "", "maintainer": "", "maintainer_email": "", "name": "completion-utils", "package_url": "https://pypi.org/project/completion-utils/", "platform": "", "project_url": "https://pypi.org/project/completion-utils/", "project_urls": { "Homepage": "https://github.com/CarvellScott/completion_utils" }, "release_url": "https://pypi.org/project/completion-utils/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "A set of functions intended to make writing shell completion functions lot easier by letting you write them via python.", "version": "0.0.2" }, "last_serial": 5212000, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "cbed56c19025bbab11c56a8cee9ac72c", "sha256": "4691fdf8222163b940cd52f092e9dfd82fef16837ab7bfe94f596d9abbb87115" }, "downloads": -1, "filename": "completion_utils-0.0.1.tar.gz", "has_sig": false, "md5_digest": "cbed56c19025bbab11c56a8cee9ac72c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7576, "upload_time": "2019-05-01T09:08:53", "url": "https://files.pythonhosted.org/packages/8c/78/c3477e2caa3b0d58c6707e647d314c807ae547b78d8f5d290c503abe6c83/completion_utils-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "095abe13e6abef217604e264f479f46e", "sha256": "5eb2e0c77a3f04e22f6a9e4f861214ec6df81615350af24a2b73fbb2e39c6bc3" }, "downloads": -1, "filename": "completion_utils-0.0.2.tar.gz", "has_sig": false, "md5_digest": "095abe13e6abef217604e264f479f46e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7601, "upload_time": "2019-05-01T09:21:32", "url": "https://files.pythonhosted.org/packages/6c/6f/a64e8a1657620dbcbb2f22f0c3bf4b027e8c54e2795be02ed407695319a6/completion_utils-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "095abe13e6abef217604e264f479f46e", "sha256": "5eb2e0c77a3f04e22f6a9e4f861214ec6df81615350af24a2b73fbb2e39c6bc3" }, "downloads": -1, "filename": "completion_utils-0.0.2.tar.gz", "has_sig": false, "md5_digest": "095abe13e6abef217604e264f479f46e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7601, "upload_time": "2019-05-01T09:21:32", "url": "https://files.pythonhosted.org/packages/6c/6f/a64e8a1657620dbcbb2f22f0c3bf4b027e8c54e2795be02ed407695319a6/completion_utils-0.0.2.tar.gz" } ] }