-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Labels
CLIAffects the CLI APIAffects the CLI APIbuildChanges that affect the build system or external dependenciesChanges that affect the build system or external dependenciesfeat/enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is needed / contributions welcomeExtra attention is needed / contributions welcome
Description
Summary
@dantrim has shown very nicely with his hamming-codec project that Typer provides a nice Click based CLI interface with typing support to minimize the amount of code that needs to be written. I now also see that Typer nicely motivates shell completions for the user
$ docker run --rm -ti python:3.9 /bin/bash
root@c66abf9f4a80:/# python -m venv venv && . venv/bin/activate
(venv) root@c66abf9f4a80:/# python -m pip --quiet install --upgrade pip setuptools wheel
(venv) root@c66abf9f4a80:/# python -m pip install hamming-codec
(venv) root@c66abf9f4a80:/# hamming --help
Usage: hamming [OPTIONS] COMMAND [ARGS]...
Top-level entrypoint into hamming-codec commandline utilities
Options:
-v, --verbose Verbose output
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.
Commands:
decode Decode the input message that is the specified number of bits...
encode Encode the provided input data word, which is interpreted as...
(venv) root@c66abf9f4a80:/# hamming --install-completion bash
bash completion installed in /root/.bash_completions/hamming.sh
Completion will take effect once you restart the terminal
(venv) root@c66abf9f4a80:/# . ~/.bashrc # As in Docker manually source, as can't make a new tab easily
(venv) root@c66abf9f4a80:/# hamming # tab here
decode encode
(venv) root@c66abf9f4a80:/# hammingTo me this is a huge selling point on its own. 👍
Additional Information
https://github.com/click-contrib/click-completion is no longer developed (last commit in 2019) so probably best to move off of it.
This is Click's current approach to shell completion: https://click.palletsprojects.com/en/8.0.x/shell-completion/
Code of Conduct
- I agree to follow the Code of Conduct
Metadata
Metadata
Assignees
Labels
CLIAffects the CLI APIAffects the CLI APIbuildChanges that affect the build system or external dependenciesChanges that affect the build system or external dependenciesfeat/enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is needed / contributions welcomeExtra attention is needed / contributions welcome
Type
Projects
Status
To do