{"id":18905491,"url":"https://github.com/utility-libraries/shell-complete-py","last_synced_at":"2026-05-14T12:34:10.152Z","repository":{"id":209066052,"uuid":"723152559","full_name":"utility-libraries/shell-complete-py","owner":"utility-libraries","description":"python package to generate shell-completion for your CLI","archived":false,"fork":false,"pushed_at":"2024-07-27T10:30:13.000Z","size":117,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T06:47:35.849Z","etag":null,"topics":["argparse","autocompletion","python3","shell"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/shell-complete/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utility-libraries.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-24T20:36:46.000Z","updated_at":"2024-07-27T10:30:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b55e502-67a9-49e3-8bf4-e9736920ffca","html_url":"https://github.com/utility-libraries/shell-complete-py","commit_stats":null,"previous_names":["utility-libraries/shell-complete-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/utility-libraries/shell-complete-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fshell-complete-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fshell-complete-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fshell-complete-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fshell-complete-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utility-libraries","download_url":"https://codeload.github.com/utility-libraries/shell-complete-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utility-libraries%2Fshell-complete-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33025115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argparse","autocompletion","python3","shell"],"created_at":"2024-11-08T09:12:10.706Z","updated_at":"2026-05-14T12:34:10.134Z","avatar_url":"https://github.com/utility-libraries.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CodeQL](https://github.com/utility-libraries/shell-complete-py/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/utility-libraries/shell-complete-py/actions/workflows/github-code-scanning/codeql)\n[![Python Testing](https://github.com/utility-libraries/shell-complete-py/actions/workflows/python-testing.yml/badge.svg)](https://github.com/utility-libraries/shell-complete-py/actions/workflows/python-testing.yml)\n\n# shell-complete-py\npython package to generate shell-completion for your CLI\n\n\u003c!-- TOC --\u003e\n* [shell-complete-py](#shell-complete-py)\n  * [Installation](#installation)\n  * [Quick-Start](#quick-start)\n    * [Installation](#installation-1)\n    * [Testing if everything works](#testing-if-everything-works)\n  * [Usage](#usage)\n  * [Support completion types](#support-completion-types)\n\u003c!-- TOC --\u003e\n\n## Installation\n\n[![PyPI - Version](https://img.shields.io/pypi/v/shell-complete)](https://pypi.org/project/shell-complete/)\n\n```bash\npip3 install shell-complete\n```\n\n## Quick-Start\n\n### Installation\n\n```shell\npip3 install shell-complete\n```\n\n### Testing if everything works\n\nTo test if the package was installed successfully\n\n```shell\n$ eval \"$(shell-complete shell_complete.__main__:parser)\"  # via CLI\n$ eval \"$(shell-complete --completion)\"  # via ShellCompleteAction\n$ shell-complete \u003ctab\u003e\u003ctab\u003e\n--completion  --help        --root        --version\n$ shell-complete --root \u003ctab\u003e\u003ctab\u003e\ndir/ .git/ .venv/  # example. this part will look different on your machine\n```\n\nor pipe it into a file and source that\n\n```shell\n$ shell-complete --completion \u003e ./shell-complete.completion.bash\n$ source ./shell-complete.completion.bash\n```\n\n## Usage\n\nEither import and use the `generate(parser: ArgumentParser)` function directly or add the `ShellCompleteAction` to your argparse.\n\n```python\nimport pathlib\nfrom argparse import ArgumentParser\nfrom shell_complete import ShellCompleteAction, types, associate\n\n\nparser = ArgumentParser(prog=\"myprog\")\n...\n# creates the --completion argument that's similar to --help or --version\n# --completion print : prints the script for the user to handle it himself or use with eval\n# --completion install : creates script in ~/.bash_completion.d/ and `source \u003cscript\u003e` in ~/.bashrc\n# --completion uninstall : removes script in ~/.bash_completion.d/ and `source \u003cscript\u003e` in ~/.bashrc\nparser.add_argument('--completion', action=ShellCompleteAction,\n                    help=\"Generate a bash-completion-script\")\n\n# add custom type converter that can still auto-complete\n@associate(types.directory)\ndef dirtype(value: str) -\u003e pathlib.Path:\n    return pathlib.Path(value)\n\n# smart autocompletion\nparser.add_argument('--dest', type=dirtype)  # the custom type\nparser.add_argument('--source', type=types.file)  # or the builtins\nparser.add_argument('--bind', type=types.ip_address)\nparser.add_argument('--database', type=types.known_hosts)\n\n# subparsers are also supported\nsubparsers = parser.add_subparsers()\nsubcommand = subparsers.add_parser(\"sub\")\n# Completion is only suggested after typing `myprog sub`\nsubcommand.add_argument('--hidden', types=types.ip_address)\n```\n\nYou can also execute the module itself\n\n```bash\npython3 -m shell_complete [--root ROOT] parser\n```\n\nOr run the console-script\n\n```bash\nshell-complete [--root ROOT] parser\n```\n\n## Support completion types\n\nBasic completion types can be imported via\n\n```python\nfrom shell_complete import types\nfrom shell_complete.argparse import types  # both are the same\n```\n\n| type                      | info                                    |\n|---------------------------|-----------------------------------------|\n| `types.path`              | any type of path (file and directories) |\n| `types.file`              | completion for files                    |\n| `types.directory`         | completion for directories              |\n| `types.mac_address`       | mac addresses                           |\n| `types.ip_address`        | ip addresses                            |\n| `types.ipv4_address`      | ipv4 addresses                          |\n| `types.ipv6_address`      | ipv6 addresses                          |\n| `types.network_interface` | names of network interfaces             |\n| `types.inet_services`     | names of inet services                  |\n| `types.uid`               | available user id's                     |\n| `types.gid`               | available group id's                    |\n| `types.service`           | available systemctl services            |\n| `types.user_group`        | user:group pair                         |\n| `types.user_at_host`      | user@host pair                          |\n| `types.known_hosts`       | name of known hosts                     |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futility-libraries%2Fshell-complete-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futility-libraries%2Fshell-complete-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futility-libraries%2Fshell-complete-py/lists"}