- Notifications
You must be signed in to change notification settings - Fork0
Example on how to set up shell autocomplete for Python scripts.
License
ggirelli/python-click-autocomplete-example
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is an example on how to set up shell autocompletion for your Python scripts reading input viaclick, especially when working on a Python package usingPoetry.
To test this example you will need:
- Python v3.8+
- Poetry
Set up the example's environment and enter it with:
git clone https://github.com/ggirelli/python-click-autocomplete-example.gitcd python-click-autocomplete-examplepoetry installpoetry shell
This example package provides you with two scripts:
clicko
is a placeholder mimicking a normal script with subcommands and commands.clicko-autocomplete
can be used to enable autocompletion for theclicko
script.
Currently, autocompletion is supported forbash
,fish
, andzsh
. To activate it, simply run:
clicko-autocomplete -s SHELL_TYPE
The defaultSHELL_TYPE
isbash
.
Now, you should be able to test autocompletion by typingclicko <TAB> <TAB>
.
Theclicko-autocomplete
script is able to generate and install shell autocompletion configuration files, stored by default in theautocomplete
subfolder of this package. This is done by exploiting the in-built autocompletion tools served byclick
.
When installing the autocompletion configuration files forbash
orzsh
, theclicko-autocomplete
script is able to check if the config files were already installed, and avoid re-installation.
To read more on autocompletion withclick
, check outtheir documentation.
About
Example on how to set up shell autocomplete for Python scripts.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.