ctctl/bash_completion

29 lines
886 B
Bash

_ctctl(){
local cur prev
_init_completion || return
case $prev in
auth|disconnect|prep|current|tokens|list|volumes|logs|conf)
return
;;
build|build-no-cache)
COMPREPLY=($(compgen -W "$(
(
for JOB in $(find . -maxdepth 1 \( -name \*.nomad -o -name \*.nomad.hcl \)); do
nomad run -output $JOB | jq '.Job.TaskGroups' | jq '.[] | .Tasks' | jq -r '.[] | .Config.image' 2>/dev/null;
done
) | perl -ne 'print "$1 " if /^oci\.ehtrace\.com\/([^:]+):.*/' | sort -u)
" -- $cur))
return
;;
switch)
COMPREPLY=($(compgen -W "$(ls -1 ~/.ctctl/*/bashrc | xargs dirname | xargs basename -a)" -- "$cur"))
return
;;
esac
COMPREPLY=($(compgen -W 'auth switch current disconnect prep tokens list build build-no-cache volumes logs conf' -- "$cur"))
} &&
complete -F _ctctl ctctl