diff --git a/cli/cli.go b/cli/cli.go index 5a89053d..e0090bae 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -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 " 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 " to test things are working, you should see app domains listed! `, autocompletionFile)) } diff --git a/scripts/autocomplete/fish b/scripts/autocomplete/fish new file mode 100644 index 00000000..54427187 --- /dev/null +++ b/scripts/autocomplete/fish @@ -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' diff --git a/tests/integration/autocomplete.sh b/tests/integration/autocomplete.sh index ebac80de..4ea2ef88 100755 --- a/tests/integration/autocomplete.sh +++ b/tests/integration/autocomplete.sh @@ -8,3 +8,5 @@ run_test '$ABRA autocomplete bash' run_test '$ABRA autocomplete fizsh' run_test '$ABRA autocomplete zsh' + +run_test '$ABRA autocomplete fish'