Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using Typer over Click #1674

Open
1 task done
matthewfeickert opened this issue Oct 26, 2021 · 2 comments · May be fixed by #1675
Open
1 task done

Switch to using Typer over Click #1674

matthewfeickert opened this issue Oct 26, 2021 · 2 comments · May be fixed by #1675
Labels
build Changes that affect the build system or external dependencies CLI Affects the CLI API feat/enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed / contributions welcome

Comments

@matthewfeickert
Copy link
Member

matthewfeickert commented Oct 26, 2021

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:/# hamming

To 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
@matthewfeickert matthewfeickert added feat/enhancement New feature or request good first issue Good for newcomers build Changes that affect the build system or external dependencies CLI Affects the CLI API labels Oct 26, 2021
@matthewfeickert matthewfeickert added this to To do in v0.7.0 via automation Oct 26, 2021
@matthewfeickert matthewfeickert added the help wanted Extra attention is needed / contributions welcome label Oct 26, 2021
@matthewfeickert
Copy link
Member Author

This is the PR in which @dantrim switched hamming-codec from Click to Typer: dantrim/hamming-codec#13 Looks very nice and easy. 👍

@matthewfeickert
Copy link
Member Author

I'm starting to poke at this on a branch feat/change-from-click-to-typer

@matthewfeickert matthewfeickert linked a pull request Oct 28, 2021 that will close this issue
4 tasks
@matthewfeickert matthewfeickert removed this from To do in v0.7.0 Dec 7, 2021
@matthewfeickert matthewfeickert added this to To do in v0.7.1 via automation Dec 7, 2021
@matthewfeickert matthewfeickert removed this from To do in v0.7.1 Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Changes that affect the build system or external dependencies CLI Affects the CLI API feat/enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed / contributions welcome
Projects
Status: To do
Development

Successfully merging a pull request may close this issue.

1 participant