この bash 補完機能を理解しようとしていますか? (cloudfoundry cli の場合)
https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_2とhttps://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion
の bash ref ガイドを読み まし
たが、理解できますcloudfoundry のスクリプト内のコードがどのように機能するかを説明します: (からコピー/usr/local/etc/bash_completion.d/cf
)
_cf() {
# All arguments except the first one
args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
# Only split on newlines
local IFS=$'
'
# Call completion (note that the first element of COMP_WORDS is
# the executable itself)
COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 0
}
complete -F _cf cf
いくつかのプラグインを cf にインストールしましたが、それらを完成させたいと思っています。(例: github.com cf-targets-plugin
)
ヒントはありますか?単語リストはどのように生成されますか? (私はその中にあると仮定しますCOMP_WORDS[]
)
これは、次のようなサンプルとは大きく異なります
COMPREPLY=( $(compgen -W "$worldist -- "$cur_opt") )