{"id":16913433,"url":"https://github.com/frostming/pycomplete","last_synced_at":"2025-09-13T15:47:03.197Z","repository":{"id":83123229,"uuid":"304540013","full_name":"frostming/pycomplete","owner":"frostming","description":"A Python library to generate static completion scripts for your CLI app","archived":false,"fork":false,"pushed_at":"2023-06-26T10:33:10.000Z","size":69,"stargazers_count":26,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-26T08:02:58.005Z","etag":null,"topics":["argparse","bash","cli","completion","fish","powershell","zsh"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frostming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-10-16T06:32:54.000Z","updated_at":"2025-04-06T14:58:21.000Z","dependencies_parsed_at":"2023-05-28T13:15:37.535Z","dependency_job_id":"e3b320d3-6fec-40f4-a257-7aed2f482341","html_url":"https://github.com/frostming/pycomplete","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.038461538461538436","last_synced_commit":"ecbf19f883247d2f2415356a03ac118433defa7e"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/frostming/pycomplete","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fpycomplete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fpycomplete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fpycomplete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fpycomplete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frostming","download_url":"https://codeload.github.com/frostming/pycomplete/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fpycomplete/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263093990,"owners_count":23412905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","bash","cli","completion","fish","powershell","zsh"],"created_at":"2024-10-13T19:13:23.968Z","updated_at":"2025-07-02T07:32:56.586Z","avatar_url":"https://github.com/frostming.png","language":"Python","readme":"# pycomplete\n\nA Python library to generate static completion scripts for your CLI app\n\n![Tests](https://github.com/frostming/pycomplete/workflows/Tests/badge.svg)\n[![PyPI](https://img.shields.io/pypi/v/pycomplete)](https://pypi.org/project/pycomplete)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pycomplete)](https://pypi.org/project/pycomplete)\n![Supported Shells - bash|zsh|fish|powershell](https://img.shields.io/badge/shell-bash%7Czsh%7Cfish%7Cpowershell-yellow)\n\n## Installation\n\n`pycomplete` requires Python 3.6 or higher, you can install it via PyPI:\n\n```bash\n$ pip install pycomplete\n```\n\n## Usage\n\nWith `pycomplete`, one can generate a completion script for CLI application that is compatible with a given shell.\nThe script outputs the result onto `stdout`, allowing one to re-direct the output to the file of their choosing.\n\n`pycomplete` accepts different types of objects depending on which CLI framework you are using.\nFor `argparse`, `argparse.ArgumentParser` is expected while for `click`, either `click.Command` or `click.Context` is OK.\n`pycomplete` knows what to do smartly.\n\nWhere you place the file will depend on which shell, and which operating system you are using.\nYour particular configuration may also determine where these scripts need to be placed.\n\nNote that `pycomplete` needs to be installed in the same environment as the target CLI app to work properly.\n\nHere are some common set ups for the three supported shells under Unix and similar operating systems (such as GNU/Linux).\n\n### BASH\n\nCompletion files are commonly stored in `/etc/bash_completion.d/`. Run command:\n\n```bash\n$ pycomplete \"myscript:parser\" bash \u003e /etc/bash_completion.d/_myscript\n```\n\nYou may have to log out and log back in to your shell session for the changes to take effect.\n\n### FISH\n\nFish completion files are commonly stored in`$HOME/.config/fish/completions/`. Run command:\n\n```bash\n$ pycomplete \"myscript:parser\" fish \u003e $HOME/.config/fish/completions/myscript.fish\n```\n\nYou may have to log out and log back in to your shell session for the changes to take effect.\n\n### ZSH\n\nZSH completions are commonly stored in any directory listed in your `$fpath` variable. To use these completions, you\nmust either add the generated script to one of those directories, or add your own to this list.\n\nAdding a custom directory is often the safest best if you're unsure of which directory to use. First create the directory, for this\nexample we'll create a hidden directory inside our `$HOME` directory\n\n```bash\n$ mkdir ~/.zfunc\n```\n\nThen add the following lines to your `.zshrc` just before `compinit`\n\n```bash\n$ fpath+=~/.zfunc\n```\n\nRun command:\n\n```bash\n$ pycomplete \"myscript:parser\" zsh \u003e ~/.zfunc/_myscript\n```\n\nYou must then either log out and log back in, or simply run\n\n```bash\n$ exec zsh\n```\n\nFor the new completions to take affect.\n\n### Powershell\n\nThere is no default location for completion scripts on Powershell. One may need to execute the scripts in their profile:\n\n```powershell\nPS \u003e mkdir $PROFILE\\..\\Completions\nPS \u003e echo @'\nGet-ChildItem \"$PROFILE\\..\\Completions\\\" | ForEach-Object {\n    . $_.FullName\n}\n'@ | Out-File -Append -Encoding utf8 $PROFILE\n```\n\nMake sure you set the proper [Execution Policy](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy):\n\n```powershell\nPS \u003e Set-ExecutionPolicy Unrestricted -Scope CurrentUser\n```\n\nRun command to generate script:\n\n```powershell\nPS \u003e pycomplete \"myscript:parser\" powershell | Out-File -Encoding utf8 $PROFILE\\..\\Completions\\myscript_completion.ps1\n```\n\nYou may have to log out and log back in to your shell session for the changes to take effect.\n\n### CUSTOM LOCATIONS\n\nAlternatively, you could save these files to the place of your choosing, such as a custom directory inside your \\$HOME. Doing so will\nrequire you to add the proper directives, such as `source`ing inside your login script. Consult your shells documentation for how to\nadd such directives.\n\n### Integrate with existing CLI apps\n\n`pycomplete` can be also used as a Python library, allowing one to integrate with existing CLI apps.\n\n```python\nfrom pycomplete import Completer\nfrom mypackage.cli import parser\n\ncompleter = Completer(parser)\nprint(completer.render())\n```\n\nSee `examples/` folder for full examples of working apps.\n\n## How does it differ from `argcomplete`?\n\n`argcomplete`, together with `click-completion`, can also generate scripts for shell completion. However, they work in a different way\nthat commands and options are retrieved on the fly when they are requested by a matching token. This brings a performance shrinkage\nwhen it is expensive to import the CLI app. In the other side, `pycomplete` produces **static and fixed** scripts which contain all required information\nwithin themselves. Plus, `argcomplete` and `click-completion` both work for specific framework. One may notice the disadvantage of static completion\nis also obvious -- users must regenerate the script when the commands and/or options are updated. Fortunately, it shouldn't be a problem\nin most package managers like `homebrew`, where completion scripts are part of the package and are bundled with it.\n\n## Limitations\n\nOnly options and subcommands are autocompleted, positional arguments are not completed since user usually expects the path sugguestion to work\nin this case.\n\n## Supported CLI Frameworks\n\n- [x] `argparse.ArgumentParser`\n- [x] `click.Command`, `click.Context`\n- [ ] More to be added\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrostming%2Fpycomplete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrostming%2Fpycomplete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrostming%2Fpycomplete/lists"}