Improve knife-solo support in knife command

This commit is contained in:
Masato Ikeda 2014-11-08 01:24:03 +09:00
commit 242328bd81

View file

@ -28,10 +28,10 @@ _knife() {
'4: :->knifesubcmd3' \ '4: :->knifesubcmd3' \
'5: :->knifesubcmd4' \ '5: :->knifesubcmd4' \
'6: :->knifesubcmd5' '6: :->knifesubcmd5'
case $state in case $state in
knifecmd) knifecmd)
compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search ssh status upload vault windows $cloudproviders compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search solo ssh status upload vault windows $cloudproviders
;; ;;
knifesubcmd) knifesubcmd)
case $words[2] in case $words[2] in
@ -61,7 +61,10 @@ _knife() {
;; ;;
role) role)
compadd -Q "$@" "bulk delete" create delete edit "from file" list show compadd -Q "$@" "bulk delete" create delete edit "from file" list show
;; ;;
solo)
compadd "$@" bootstrap clean cook init prepare
;;
upload) upload)
_arguments '*:file or directory:_files -g "*"' _arguments '*:file or directory:_files -g "*"'
;; ;;
@ -98,6 +101,12 @@ _knife() {
bag) bag)
compadd -Q "$@" show edit list "from file" create delete compadd -Q "$@" show edit list "from file" create delete
;; ;;
(bootstrap|clean|cook|prepare)
for json in $(ls -1 nodes/*.json); do compadd "$@" $(basename $json .json); done
;;
init)
for dir in $(find . -type d -maxdepth 1); do compadd "$@" $(basename $dir); done
;;
*) *)
_arguments '3:Subsubcommands:($(_knife_options2))' _arguments '3:Subsubcommands:($(_knife_options2))'
esac esac
@ -134,8 +143,8 @@ _knife() {
else else
_arguments '*:Subsubcommands:($(_knife_options2))' _arguments '*:Subsubcommands:($(_knife_options2))'
fi fi
;; ;;
knifesubcmd5) knifesubcmd5)
_arguments '*:Subsubcommands:($(_knife_options3))' _arguments '*:Subsubcommands:($(_knife_options3))'
esac esac
} }
@ -184,7 +193,7 @@ _chef_environments_remote() {
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
_chef_cookbooks_local() { _chef_cookbooks_local() {
local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb} local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
if [ -f ./.chef/knife.rb ]; then if [ -f ./.chef/knife.rb ]; then
knife_rb="./.chef/knife.rb" knife_rb="./.chef/knife.rb"