132607447d24477bcedac7e0accd3fe83b9b6a1a
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/knife/README.md b/plugins/knife/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..b167f16553431328c43af92e79381ed55b36de75
4--- /dev/null
5+++ b/plugins/knife/README.md
6@@ -0,0 +1,25 @@
7+# knife plugin
8+
9+This plugin adds completion for [knife](https://docs.chef.io/knife.html), a command-line tool
10+to interact with [Chef](https://chef.io), a platform to automate and manage infrastructure via
11+code.
12+
13+To use it, add `knife` to the plugins array in your zshrc file:
14+```zsh
15+plugins=(... knife)
16+```
17+
18+## Options
19+
20+- `KNIFE_RELATIVE_PATH`: if set to `true`, the completion script will look for local cookbooks
21+ under the `cookbooks` folder in the chef root directory. It has preference over the other two
22+ options below. **Default:** empty.
23+
24+- `KNIFE_COOKBOOK_PATH`: if set, it points to the folder that contains local cookbooks, for
25+ example: `/path/to/my/chef/cookbooks`. **Default:** `cookbook_path` field in `knife.rb`
26+ (see below).
27+
28+- `KNIFE_CONF_PATH`: variable pointing to the `knife.rb` configuration file, for example
29+ `/path/to/my/.chef/knife.rb`. Only used if `$KNIFE_COOKBOOK_PATH` isn't set. If it exists,
30+ `$PWD/.chef/knife.rb` is used instead. Otherwise, if it's set, its value is used.
31+ **Default**: `$HOME/.chef/knife.rb`.
32diff --git a/plugins/knife/_knife b/plugins/knife/_knife
33index 0d61ff15c5d9614e05fd662be261551c31915cfb..06b12a3b00e762d46fb9d2a2a0aec4fec6be5bb5 100644
34--- a/plugins/knife/_knife
35+++ b/plugins/knife/_knife
36@@ -3,13 +3,13 @@
37 # You can override the path to knife.rb and your cookbooks by setting
38 # KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb
39 # KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks
40-# If you want your local cookbooks path to be calculated relative to where you are then
41+# If you want your local cookbooks path to be calculated relative to where you are then
42 # set the below option
43-# KNIFE_RELATIVE_PATH=true
44+# KNIFE_RELATIVE_PATH=true
45 # Read around where these are used for more detail.
46
47 # These flags should be available everywhere according to man knife
48-knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes )
49+knife_general_flags=(--help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes)
50
51 # knife has a very special syntax, some example calls are:
52 # knife status
53@@ -25,183 +25,191 @@ _knife() {
54 typeset -A opt_args
55 cloudproviders=(bluebox ec2 rackspace slicehost terremark)
56 _arguments \
57- '1: :->knifecmd'\
58- '2: :->knifesubcmd'\
59+ '1: :->knifecmd' \
60+ '2: :->knifesubcmd' \
61 '3: :->knifesubcmd2' \
62 '4: :->knifesubcmd3' \
63 '5: :->knifesubcmd4' \
64 '6: :->knifesubcmd5'
65-
66+
67 case $state in
68 knifecmd)
69 compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search ssh status upload vault windows $cloudproviders
70- ;;
71+ ;;
72 knifesubcmd)
73 case $words[2] in
74- (bluebox|ec2|rackspace|slicehost|terremark)
75+ bluebox|ec2|rackspace|slicehost|terremark)
76 compadd "$@" server images
77- ;;
78+ ;;
79 client)
80 compadd -Q "$@" "bulk delete" list create show delete edit reregister
81- ;;
82+ ;;
83 configure)
84 compadd "$@" client
85- ;;
86+ ;;
87 cookbook)
88 compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload
89- ;;
90+ ;;
91 diff)
92 _arguments '*:file or directory:_files -g "*"'
93- ;;
94+ ;;
95 environment)
96 compadd -Q "$@" list create delete edit show "from file"
97- ;;
98+ ;;
99 node)
100- compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
101- ;;
102+ compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
103+ ;;
104 recipe)
105- compadd "$@" list
106- ;;
107+ compadd "$@" list
108+ ;;
109 role)
110 compadd -Q "$@" "bulk delete" create delete edit "from file" list show
111- ;;
112+ ;;
113 upload)
114- _arguments '*:file or directory:_files -g "*"'
115- ;;
116+ _arguments '*:file or directory:_files -g "*"'
117+ ;;
118 vault)
119 compadd -Q "$@" create decrypt delete edit remove "rotate all keys" "rotate keys" show update
120- ;;
121+ ;;
122 windows)
123 compadd "$@" bootstrap
124- ;;
125+ ;;
126 *)
127- _arguments '2:Subsubcommands:($(_knife_options1))'
128+ _arguments '2:Subsubcommands:($(_knife_options1))'
129+ ;;
130 esac
131- ;;
132- knifesubcmd2)
133+ ;;
134+ knifesubcmd2)
135 case $words[3] in