completion: add help and syncconf completions

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-12-13 22:29:09 +01:00
parent 5e24780d4c
commit 7e506135f7

View file

@ -5,12 +5,12 @@ _wg_completion() {
local a local a
if [[ $COMP_CWORD -eq 1 ]]; then if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY+=( $(compgen -W "show showconf set setconf addconf genkey genpsk pubkey" -- "${COMP_WORDS[1]}") ) COMPREPLY+=( $(compgen -W "help show showconf set setconf addconf syncconf genkey genpsk pubkey" -- "${COMP_WORDS[1]}") )
return return
fi fi
case "${COMP_WORDS[1]}" in case "${COMP_WORDS[1]}" in
genkey|genpsk|pubkey|help) return; ;; genkey|genpsk|pubkey|help) return; ;;
show|showconf|set|setconf|addconf) ;; show|showconf|set|setconf|addconf|syncconf) ;;
*) return; *) return;
esac esac
@ -26,7 +26,7 @@ _wg_completion() {
return return
fi fi
if [[ $COMP_CWORD -eq 3 && ( ${COMP_WORDS[1]} == setconf || ${COMP_WORDS[1]} == addconf ) ]]; then if [[ $COMP_CWORD -eq 3 && ( ${COMP_WORDS[1]} == setconf || ${COMP_WORDS[1]} == addconf || ${COMP_WORDS[1]} == syncconf) ]]; then
compopt -o filenames compopt -o filenames
mapfile -t a < <(compgen -f -- "${COMP_WORDS[3]}") mapfile -t a < <(compgen -f -- "${COMP_WORDS[3]}")
COMPREPLY+=( "${a[@]}" ) COMPREPLY+=( "${a[@]}" )