From 05b11e83d429b8dc796116a590ac2d3865b314d0 Mon Sep 17 00:00:00 2001 From: Ines Moreau Date: Wed, 29 Jul 2026 11:11:00 +0200 Subject: [PATCH] Add bash and zsh completions Implements: https://todo.hut.md/~reviewer/hello-hut/9 --- contrib/completions/_hello-hut | 11 +++++++++++ contrib/completions/hello-hut.bash | 16 ++++++++++++++++ docs/install.md | 9 +++++++++ 3 files changed, 36 insertions(+) create mode 100644 contrib/completions/_hello-hut create mode 100644 contrib/completions/hello-hut.bash diff --git a/contrib/completions/_hello-hut b/contrib/completions/_hello-hut new file mode 100644 index 0000000000000000000000000000000000000000..ecb9dfa9223a1934974776e27762a1aa7c5ac8d0 --- /dev/null +++ b/contrib/completions/_hello-hut @@ -0,0 +1,11 @@ +#compdef hello-hut +# zsh completion for hello-hut; copy into a directory on your $fpath. + +_arguments \ + '--shout[print the greeting in capitals]' \ + '--time-of-day[say good morning, afternoon or evening]' \ + '--count[repeat the greeting]:count:' \ + '--color[colorize the output]:when:(auto always never)' \ + '--format[output format]:format:(text json)' \ + '--version[show the version and exit]' \ + '1::name:' diff --git a/contrib/completions/hello-hut.bash b/contrib/completions/hello-hut.bash new file mode 100644 index 0000000000000000000000000000000000000000..c3273830784720d87e74ad4e6bf3e36ad42df0f3 --- /dev/null +++ b/contrib/completions/hello-hut.bash @@ -0,0 +1,16 @@ +# bash completion for hello-hut +# Copy to ~/.local/share/bash-completion/completions/hello-hut + +_hello_hut() { + local cur opts + cur="${COMP_WORDS[COMP_CWORD]}" + opts="--shout --time-of-day --count --color --format --version --help" + case "${COMP_WORDS[COMP_CWORD-1]}" in + --color) COMPREPLY=($(compgen -W "auto always never" -- "$cur")); return ;; + --format) COMPREPLY=($(compgen -W "text json" -- "$cur")); return ;; + esac + if [[ "$cur" == -* ]]; then + COMPREPLY=($(compgen -W "$opts" -- "$cur")) + fi +} +complete -F _hello_hut hello-hut diff --git a/docs/install.md b/docs/install.md index 719aa222cbc485b047474dd49e749c20d7d45d9b..28208d58cb75aaaa679a476291d3d02583eedcd9 100644 --- a/docs/install.md +++ b/docs/install.md @@ -22,4 +22,13 @@ To try it without installing anything: PYTHONPATH=src python3 -m hello_hut Ada ``` +## Shell completions + +Bash and zsh completions live in `contrib/completions/`: + +| Shell | Copy this file | To | +| --- | --- | --- | +| bash | `hello-hut.bash` | `~/.local/share/bash-completion/completions/hello-hut` | +| zsh | `_hello-hut` | any directory on your `$fpath` | + Next: [configure hello-hut](configuration.md).