mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-12 20:21:02 +01:00
knife: add README and reformat completion file
This commit is contained in:
parent
a952854c12
commit
132607447d
2 changed files with 136 additions and 104 deletions
25
plugins/knife/README.md
Normal file
25
plugins/knife/README.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# knife plugin
|
||||
|
||||
This plugin adds completion for [knife](https://docs.chef.io/knife.html), a command-line tool
|
||||
to interact with [Chef](https://chef.io), a platform to automate and manage infrastructure via
|
||||
code.
|
||||
|
||||
To use it, add `knife` to the plugins array in your zshrc file:
|
||||
```zsh
|
||||
plugins=(... knife)
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
- `KNIFE_RELATIVE_PATH`: if set to `true`, the completion script will look for local cookbooks
|
||||
under the `cookbooks` folder in the chef root directory. It has preference over the other two
|
||||
options below. **Default:** empty.
|
||||
|
||||
- `KNIFE_COOKBOOK_PATH`: if set, it points to the folder that contains local cookbooks, for
|
||||
example: `/path/to/my/chef/cookbooks`. **Default:** `cookbook_path` field in `knife.rb`
|
||||
(see below).
|
||||
|
||||
- `KNIFE_CONF_PATH`: variable pointing to the `knife.rb` configuration file, for example
|
||||
`/path/to/my/.chef/knife.rb`. Only used if `$KNIFE_COOKBOOK_PATH` isn't set. If it exists,
|
||||
`$PWD/.chef/knife.rb` is used instead. Otherwise, if it's set, its value is used.
|
||||
**Default**: `$HOME/.chef/knife.rb`.
|
|
@ -38,7 +38,7 @@ _knife() {
|
|||
;;
|
||||
knifesubcmd)
|
||||
case $words[2] in
|
||||
(bluebox|ec2|rackspace|slicehost|terremark)
|
||||
bluebox|ec2|rackspace|slicehost|terremark)
|
||||
compadd "$@" server images
|
||||
;;
|
||||
client)
|
||||
|
@ -76,6 +76,7 @@ _knife() {
|
|||
;;
|
||||
*)
|
||||
_arguments '2:Subsubcommands:($(_knife_options1))'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
knifesubcmd2)
|
||||
|
@ -89,10 +90,10 @@ _knife() {
|
|||
site)
|
||||
compadd "$@" vendor show share search download list unshare
|
||||
;;
|
||||
(show|delete|edit)
|
||||
show|delete|edit)
|
||||
_arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))'
|
||||
;;
|
||||
(upload|test)
|
||||
upload|test)
|
||||
_arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)'
|
||||
;;
|
||||
list)
|
||||
|
@ -103,6 +104,7 @@ _knife() {
|
|||
;;
|
||||
*)
|
||||
_arguments '3:Subsubcommands:($(_knife_options2))'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
knifesubcmd3)
|
||||
|
@ -113,12 +115,14 @@ _knife() {
|
|||
versioncomp=1
|
||||
_arguments '4:Cookbookversions:($(_cookbook_versions) latest)'
|
||||
;;
|
||||
(node|client|role)
|
||||
node|client|role)
|
||||
compadd "$@" --attribute
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
case $words[4] in
|
||||
(show|edit)
|
||||
show|edit)
|
||||
_arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
|
||||
;;
|
||||
file)
|
||||
|
@ -134,6 +138,7 @@ _knife() {
|
|||
;;
|
||||
*)
|
||||
_arguments '*:Subsubcommands:($(_knife_options3))'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
list)
|
||||
|
@ -141,6 +146,7 @@ _knife() {
|
|||
;;
|
||||
*)
|
||||
_arguments '*:Subsubcommands:($(_knife_options3))'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
knifesubcmd4)
|
||||
|
@ -151,7 +157,7 @@ _knife() {
|
|||
file)
|
||||
_arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
|
||||
;;
|
||||
*) _arguments '*:Subsubcommands:($(_knife_options2))'
|
||||
*) _arguments '*:Subsubcommands:($(_knife_options2))' ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
@ -162,7 +168,9 @@ _knife() {
|
|||
;;
|
||||
*)
|
||||
_arguments '*:Subsubcommands:($(_knife_options3))'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -231,8 +239,7 @@ _cookbook_versions() {
|
|||
# Useful for the knife upload/from file commands
|
||||
_chef_root() {
|
||||
directory="$PWD"
|
||||
while [ $directory != '/' ]
|
||||
do
|
||||
while [ $directory != '/' ]; do
|
||||
test -e "$directory/.chef" && echo "$directory" && return
|
||||
directory="${directory:h}"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue