···11+#! /bin/bash
22+# based on https://github.com/urfave/cli/blob/v2.27.6/autocomplete/bash_autocomplete
33+44+# Macs have bash3 for which the bash-completion package doesn't include
55+# _init_completion. This is a minimal version of that function.
66+_cli_init_completion() {
77+ COMPREPLY=()
88+ _get_comp_words_by_ref "$@" cur prev words cword
99+}
1010+1111+_cli_bash_autocomplete() {
1212+ if [[ "${COMP_WORDS[0]}" != "source" ]]; then
1313+ local cur opts base words
1414+ COMPREPLY=()
1515+ cur="${COMP_WORDS[COMP_CWORD]}"
1616+ if declare -F _init_completion >/dev/null 2>&1; then
1717+ _init_completion -n "=:" || return
1818+ else
1919+ _cli_init_completion -n "=:" || return
2020+ fi
2121+ words=("${words[@]:0:$cword}")
2222+ if [[ "$cur" == "-"* ]]; then
2323+ requestComp="${words[*]} ${cur} --generate-bash-completion"
2424+ else
2525+ requestComp="${words[*]} --generate-bash-completion"
2626+ fi
2727+ opts=$(eval "${requestComp}" 2>/dev/null)
2828+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2929+ return 0
3030+ fi
3131+}
3232+3333+complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete tcld
···11+#compdef $PROG
22+33+## based on https://github.com/urfave/cli/blob/v2.27.6/autocomplete/zsh_autocomplete
44+55+_cli_zsh_autocomplete() {
66+ local -a opts
77+ local cur
88+ cur=${words[-1]}
99+ if [[ "$cur" == "-"* ]]; then
1010+ opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
1111+ else
1212+ opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}")
1313+ fi
1414+1515+ if [[ "${opts[1]}" != "" ]]; then
1616+ _describe 'values' opts
1717+ else
1818+ _files
1919+ fi
2020+}
2121+2222+compdef _cli_zsh_autocomplete tcld