feat(autocomplete): add autocompletion for fish shell
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Moritz 2022-11-15 22:24:34 +01:00
parent 14187449a5
commit 521d3d1259
3 changed files with 19 additions and 1 deletions

View File

@ -29,7 +29,7 @@ var AutoCompleteCommand = cli.Command{
Description: `
Set up auto-completion in your shell by downloading the relevant files and
laying out what additional information must be loaded. Supported shells are as
follows: bash, fizsh & zsh.
follows: bash, fish, fizsh & zsh.
Example:
@ -50,6 +50,7 @@ Example:
"bash": true,
"zsh": true,
"fizsh": true,
"fish": true,
}
if _, ok := supportedShells[shellType]; !ok {
@ -93,6 +94,14 @@ sudo mkdir /etc/zsh/completion.d/
sudo cp %s /etc/zsh/completion.d/abra
echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra" >> ~/.zshrc
# And finally run "abra app ps <hit tab key>" to test things are working, you should see app domains listed!
`, autocompletionFile))
case "fish":
fmt.Println(fmt.Sprintf(`
# Run the following commands to install auto-completion
sudo mkdir -p /etc/fish/completions
sudo cp %s /etc/fish/completions/abra
echo "source /etc/fish/completions/abra" >> ~/.config/fish/config.fish
# And finally run "abra app ps <hit tab key>" to test things are working, you should see app domains listed!
`, autocompletionFile))
}

View File

@ -0,0 +1,7 @@
function complete_abra_args
set -l cmd (commandline -poc) --generate-bash-completion
$cmd
end
complete -c abra -f -n "not __fish_seen_subcommand_from -h --help -v --version complete_abra_args" -a "(complete_abra_args)"
complete -c abra -f -s h -l help -d 'show help'
complete -c abra -f -s v -l version -d 'print the version'

View File

@ -8,3 +8,5 @@ run_test '$ABRA autocomplete bash'
run_test '$ABRA autocomplete fizsh'
run_test '$ABRA autocomplete zsh'
run_test '$ABRA autocomplete fish'