~reviewer/hello-hut

05b11e83d429b8dc796116a590ac2d3865b314d0 — Ines Moreau 2 months ago 929dcec
Add bash and zsh completions

Implements: https://todo.hut.md/~reviewer/hello-hut/9
3 files changed, 36 insertions(+), 0 deletions(-)

A contrib/completions/_hello-hut
A contrib/completions/hello-hut.bash
M docs/install.md
A contrib/completions/_hello-hut => contrib/completions/_hello-hut +11 -0
@@ 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:'

A contrib/completions/hello-hut.bash => contrib/completions/hello-hut.bash +16 -0
@@ 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

M docs/install.md => docs/install.md +9 -0
@@ 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).