core/cli: autocomplete module names

This commit is contained in:
Sean Breckenridge 2022-02-21 05:29:25 -08:00 committed by karlicoss
parent 8b01674fed
commit 6185942f78
4 changed files with 21 additions and 11 deletions

View file

@ -8,7 +8,7 @@ eval "$(_HPI_COMPLETE=zsh_source hpi)" # in ~/.zshrc
eval "$(_HPI_COMPLETE=fish_source hpi)" # in ~/.config/fish/config.fish
```
That is slightly slower since its generating the completion code on the fly -- see [click docs](https://click.palletsprojects.com/en/8.0.x/shell-completion/?highlight=completion#enabling-completion) for more info
That is slightly slower since its generating the completion code on the fly -- see [click docs](https://click.palletsprojects.com/en/8.0.x/shell-completion/#enabling-completion) for more info
To use the completions here:
@ -32,4 +32,4 @@ If your zsh configuration doesn't automatically run `compinit`, after modifying
### fish
`cp ./fish/hpi.fish ~/.config/fish/completions/`, an then restart your shell
`cp ./fish/hpi.fish ~/.config/fish/completions/`, then restart your shell

View file

@ -8,10 +8,10 @@ _hpi_completion() {
IFS=',' read type value <<< "$completion"
if [[ $type == 'dir' ]]; then
COMREPLY=()
COMPREPLY=()
compopt -o dirnames
elif [[ $type == 'file' ]]; then
COMREPLY=()
COMPREPLY=()
compopt -o default
elif [[ $type == 'plain' ]]; then
COMPREPLY+=($value)