Files
versitygw/extra/versitygw.sh
Ben McClelland 14b0aabb0b feat: add cli option to generate shell auto completion
The urfave/cli/v2 has built-in auto-completion support for bash.
This enables generating the auto completions with a cli option
that can be added to environment setup scripts.

Also adding some distro support scripts for rpm and deb for the
auto completion setup.

To enable auto completion in zsh, this still needs to be added
to user .zshrc:
fpath=(/usr/share/zsh/site-functions $fpath)
autoload -Uz compinit && compinit

Fixes #2015
2026-04-13 19:17:56 -07:00

21 lines
637 B
Bash

#!/bin/bash
# Bash completion for versitygw
[ -n "$BASH_VERSION" ] || return 0
_cli_bash_autocomplete() {
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
local cur opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ "$cur" == "-"* ]]; then
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
else
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
fi
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
}
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete versitygw