hammer_cli 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hammer +3 -1
- data/config/cli_config.template.yml +3 -0
- data/doc/creating_commands.md +1 -1
- data/doc/installation.md +3 -2
- data/doc/release_notes.md +17 -0
- data/doc/writing_a_plugin.md +1 -1
- data/lib/hammer_cli/abstract.rb +46 -9
- data/lib/hammer_cli/apipie/command.rb +10 -1
- data/lib/hammer_cli/apipie/option_builder.rb +29 -11
- data/lib/hammer_cli/apipie/option_definition.rb +18 -0
- data/lib/hammer_cli/apipie/resource.rb +4 -22
- data/lib/hammer_cli/exception_handler.rb +18 -6
- data/lib/hammer_cli/exceptions.rb +1 -0
- data/lib/hammer_cli/i18n.rb +4 -0
- data/lib/hammer_cli/main.rb +2 -0
- data/lib/hammer_cli/modules.rb +30 -2
- data/lib/hammer_cli/options/matcher.rb +48 -0
- data/lib/hammer_cli/output/adapter.rb +3 -1
- data/lib/hammer_cli/output/adapter/csv.rb +5 -2
- data/lib/hammer_cli/output/adapter/json.rb +17 -0
- data/lib/hammer_cli/output/adapter/table.rb +11 -17
- data/lib/hammer_cli/output/adapter/tree_structure.rb +74 -0
- data/lib/hammer_cli/output/adapter/wrapper_formatter.rb +20 -0
- data/lib/hammer_cli/output/adapter/yaml.rb +16 -0
- data/lib/hammer_cli/shell.rb +3 -8
- data/lib/hammer_cli/utils.rb +10 -0
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/hammer-cli.po +296 -0
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/hammer-cli.po +1 -1
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/hammer-cli.po +133 -133
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/hammer-cli.po +148 -147
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/hammer-cli.po +142 -141
- data/locale/hammer-cli.pot +39 -32
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/hammer-cli.po +293 -0
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/hammer-cli.po +291 -0
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/hammer-cli.po +292 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/hammer-cli.po +294 -0
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/hammer-cli.po +293 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/hammer-cli.po +292 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/hammer-cli.po +292 -0
- data/test/unit/apipie/command_test.rb +22 -0
- data/test/unit/apipie/option_builder_test.rb +21 -7
- data/test/unit/apipie/option_definition_test.rb +26 -0
- data/test/unit/fixtures/apipie/documented.json +26 -0
- data/test/unit/modules_test.rb +13 -2
- data/test/unit/options/matcher_test.rb +61 -0
- data/test/unit/output/adapter/json_test.rb +214 -0
- data/test/unit/output/adapter/table_test.rb +66 -0
- data/test/unit/output/adapter/yaml_test.rb +213 -0
- data/test/unit/utils_test.rb +17 -0
- metadata +249 -205
Binary file
|
@@ -0,0 +1,292 @@
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
2
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3
|
+
# This file is distributed under the same license as the hammer-cli package.
|
4
|
+
#
|
5
|
+
# Translators:
|
6
|
+
# Automatically generated, 2014
|
7
|
+
msgid ""
|
8
|
+
msgstr ""
|
9
|
+
"Project-Id-Version: hammer-cli 0.1.4\n"
|
10
|
+
"Report-Msgid-Bugs-To: \n"
|
11
|
+
"POT-Creation-Date: 2014-09-15 12:50+0100\n"
|
12
|
+
"PO-Revision-Date: 2014-09-16 13:21+0000\n"
|
13
|
+
"Last-Translator: Dominic Cleal <dcleal@redhat.com>\n"
|
14
|
+
"Language-Team: Chinese (Taiwan) (http://www.transifex.com/projects/p/foreman/language/zh_TW/)\n"
|
15
|
+
"MIME-Version: 1.0\n"
|
16
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
17
|
+
"Content-Transfer-Encoding: 8bit\n"
|
18
|
+
"Language: zh_TW\n"
|
19
|
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
20
|
+
|
21
|
+
#: lib/hammer_cli/subcommand.rb:56
|
22
|
+
msgid ""
|
23
|
+
"can't replace subcommand %<name>s (%<existing_class>s) with %<name>s "
|
24
|
+
"(%<new_class>s)"
|
25
|
+
msgstr ""
|
26
|
+
|
27
|
+
#: lib/hammer_cli/logger.rb:28
|
28
|
+
msgid "No permissions to create log dir %s"
|
29
|
+
msgstr "沒有建立日誌目錄 %s 的權限"
|
30
|
+
|
31
|
+
#: lib/hammer_cli/logger.rb:43
|
32
|
+
msgid "File %s not writeable, won't log anything to the file!"
|
33
|
+
msgstr "%s 檔案不允許寫入,將不會記錄任何資料至此檔案中!"
|
34
|
+
|
35
|
+
#: lib/hammer_cli/main.rb:7
|
36
|
+
msgid "be verbose"
|
37
|
+
msgstr "詳細提供資料"
|
38
|
+
|
39
|
+
#: lib/hammer_cli/main.rb:8
|
40
|
+
msgid "show debugging output "
|
41
|
+
msgstr "顯示除錯輸出"
|
42
|
+
|
43
|
+
#: lib/hammer_cli/main.rb:9
|
44
|
+
msgid "path to custom config file"
|
45
|
+
msgstr "自訂配置檔案的路徑"
|
46
|
+
|
47
|
+
#: lib/hammer_cli/main.rb:11
|
48
|
+
msgid "username to access the remote system"
|
49
|
+
msgstr "用來存取遠端系統的使用者名稱"
|
50
|
+
|
51
|
+
#: lib/hammer_cli/main.rb:13
|
52
|
+
msgid "password to access the remote system"
|
53
|
+
msgstr "用來存取遠端系統的密碼"
|
54
|
+
|
55
|
+
#: lib/hammer_cli/main.rb:15
|
56
|
+
msgid "remote system address"
|
57
|
+
msgstr "遠端系統位址"
|
58
|
+
|
59
|
+
#: lib/hammer_cli/main.rb:18
|
60
|
+
msgid "show version"
|
61
|
+
msgstr "顯示版本"
|
62
|
+
|
63
|
+
#: lib/hammer_cli/main.rb:27
|
64
|
+
msgid "Show ids of associated resources"
|
65
|
+
msgstr "顯示相聯資源的 id"
|
66
|
+
|
67
|
+
#: lib/hammer_cli/main.rb:29
|
68
|
+
msgid "Explicitly turn interactive mode on/off"
|
69
|
+
msgstr "明確開啓或關閉互動式模式"
|
70
|
+
|
71
|
+
#: lib/hammer_cli/main.rb:33
|
72
|
+
msgid "Output as CSV (same as --output=csv)"
|
73
|
+
msgstr "輸出為 CSV(與 --output=csv 相同)"
|
74
|
+
|
75
|
+
#: lib/hammer_cli/main.rb:34
|
76
|
+
msgid "Set output format. One of [%s]"
|
77
|
+
msgstr "設定輸出模式。[%s] 之一"
|
78
|
+
|
79
|
+
#: lib/hammer_cli/main.rb:37
|
80
|
+
msgid "Character to separate the values"
|
81
|
+
msgstr "用來隔開值的字元"
|
82
|
+
|
83
|
+
#: lib/hammer_cli/main.rb:41
|
84
|
+
msgid "Get list of possible endings"
|
85
|
+
msgstr "取得一列可能的結尾"
|
86
|
+
|
87
|
+
#: lib/hammer_cli/validator.rb:41
|
88
|
+
msgid "Unknown option name '%s'"
|
89
|
+
msgstr "不明選項名稱「%s」"
|
90
|
+
|
91
|
+
#: lib/hammer_cli/validator.rb:62
|
92
|
+
msgid "You can't set all options %s at one time"
|
93
|
+
msgstr "您不可一次將所有選項設為 %s"
|
94
|
+
|
95
|
+
#: lib/hammer_cli/validator.rb:63
|
96
|
+
msgid "Options %s are required"
|
97
|
+
msgstr "%s 選項乃必要的"
|
98
|
+
|
99
|
+
#: lib/hammer_cli/validator.rb:79
|
100
|
+
msgid "You can't set any of options %s"
|
101
|
+
msgstr "您不可將任何選項設為 %s"
|
102
|
+
|
103
|
+
#: lib/hammer_cli/validator.rb:80
|
104
|
+
msgid "At least one of options %s is required"
|
105
|
+
msgstr "需要至少一項 %s 選項"
|
106
|
+
|
107
|
+
#: lib/hammer_cli/shell.rb:10
|
108
|
+
msgid "Print help for commands"
|
109
|
+
msgstr "印出指令的說明"
|
110
|
+
|
111
|
+
#: lib/hammer_cli/shell.rb:22
|
112
|
+
msgid "Exit interactive shell"
|
113
|
+
msgstr "退出互動式 shell"
|
114
|
+
|
115
|
+
#: lib/hammer_cli/shell.rb:120
|
116
|
+
msgid "Welcome to the hammer interactive shell"
|
117
|
+
msgstr "歡迎使用 hammer 互動式 shell"
|
118
|
+
|
119
|
+
#: lib/hammer_cli/shell.rb:121
|
120
|
+
msgid "Type 'help' for usage information"
|
121
|
+
msgstr "請輸入「help」以查看使用說明"
|
122
|
+
|
123
|
+
#: lib/hammer_cli/shell.rb:122
|
124
|
+
msgid ""
|
125
|
+
"Command completion is disabled on ruby < 1.9 due to compatibility problems."
|
126
|
+
msgstr "基於相容性上的問題,ruby < 1.9 上已停用了指令完成。"
|
127
|
+
|
128
|
+
#: lib/hammer_cli/shell.rb:138
|
129
|
+
msgid "Interactive shell"
|
130
|
+
msgstr "互動式 shell"
|
131
|
+
|
132
|
+
#: lib/hammer_cli/clamp.rb:5
|
133
|
+
msgid "too many arguments"
|
134
|
+
msgstr "引數過多"
|
135
|
+
|
136
|
+
#: lib/hammer_cli/clamp.rb:6
|
137
|
+
msgid "option '%<option>s' is required"
|
138
|
+
msgstr "需要使用 '%<option>s' 選項"
|
139
|
+
|
140
|
+
#: lib/hammer_cli/clamp.rb:7
|
141
|
+
msgid "option '%<option>s' (or env %<env>s) is required"
|
142
|
+
msgstr "需要使用 '%<option>s'(或是 %<env>s 環境)選項"
|
143
|
+
|
144
|
+
#: lib/hammer_cli/clamp.rb:8
|
145
|
+
msgid "option '%<switch>s': %<message>s"
|
146
|
+
msgstr "選項 '%<switch>s':%<message>s"
|
147
|
+
|
148
|
+
#: lib/hammer_cli/clamp.rb:9
|
149
|
+
msgid "parameter '%<param>s': %<message>s"
|
150
|
+
msgstr "參數 '%<param>s':%<message>s"
|
151
|
+
|
152
|
+
#: lib/hammer_cli/clamp.rb:10
|
153
|
+
msgid "%<env>s: %<message>s"
|
154
|
+
msgstr "%<env>s:%<message>s"
|
155
|
+
|
156
|
+
#: lib/hammer_cli/clamp.rb:11
|
157
|
+
msgid "Unrecognised option '%<switch>s'"
|
158
|
+
msgstr "無法辨識的選項 '%<switch>s'"
|
159
|
+
|
160
|
+
#: lib/hammer_cli/clamp.rb:12
|
161
|
+
msgid "No such sub-command '%<name>s'"
|
162
|
+
msgstr "此類型的次指令不存在:'%<name>s'"
|
163
|
+
|
164
|
+
#: lib/hammer_cli/clamp.rb:13
|
165
|
+
msgid "no value provided"
|
166
|
+
msgstr "未提供值"
|
167
|
+
|
168
|
+
#: lib/hammer_cli/options/option_definition.rb:68
|
169
|
+
msgid "Can be specified multiple times. "
|
170
|
+
msgstr "可指定多次。"
|
171
|
+
|
172
|
+
#: lib/hammer_cli/options/option_definition.rb:69
|
173
|
+
msgid "Default: "
|
174
|
+
msgstr "預設值:"
|
175
|
+
|
176
|
+
#: lib/hammer_cli/options/option_definition.rb:69
|
177
|
+
msgid ", or "
|
178
|
+
msgstr ",或是"
|
179
|
+
|
180
|
+
#: lib/hammer_cli/options/normalizers.rb:26
|
181
|
+
msgid "Comma-separated list of key=value."
|
182
|
+
msgstr "逗號區隔開的一列 key=value。"
|
183
|
+
|
184
|
+
#: lib/hammer_cli/options/normalizers.rb:39
|
185
|
+
msgid "value must be defined as a comma-separated list of key=value"
|
186
|
+
msgstr "值必須以一列逗號區隔開的 key=value 來定義"
|
187
|
+
|
188
|
+
#: lib/hammer_cli/options/normalizers.rb:57
|
189
|
+
msgid "Comma separated list of values."
|
190
|
+
msgstr "逗號區隔開的值。"
|
191
|
+
|
192
|
+
#: lib/hammer_cli/options/normalizers.rb:69
|
193
|
+
msgid "One of true/false, yes/no, 1/0."
|
194
|
+
msgstr "true/false、yes/no、1/0 之一。"
|
195
|
+
|
196
|
+
#: lib/hammer_cli/options/normalizers.rb:79
|
197
|
+
msgid "value must be one of true/false, yes/no, 1/0"
|
198
|
+
msgstr "值必須是 true/false、yes/no、1/0 之一"
|
199
|
+
|
200
|
+
#: lib/hammer_cli/options/normalizers.rb:118
|
201
|
+
msgid "Unable to parse JSON input"
|
202
|
+
msgstr "無法叵析 JSON 輸入"
|
203
|
+
|
204
|
+
#: lib/hammer_cli/options/normalizers.rb:131
|
205
|
+
msgid "One of %s"
|
206
|
+
msgstr "%s 之一"
|
207
|
+
|
208
|
+
#: lib/hammer_cli/options/normalizers.rb:138
|
209
|
+
msgid "value must be one of '%s'"
|
210
|
+
msgstr "值必須是「%s」之一"
|
211
|
+
|
212
|
+
#: lib/hammer_cli/options/normalizers.rb:157
|
213
|
+
msgid "Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format"
|
214
|
+
msgstr "日期與時間,格式為 YYYY-MM-DD HH:MM:SS 或是 ISO 8601 格式"
|
215
|
+
|
216
|
+
#: lib/hammer_cli/options/normalizers.rb:164
|
217
|
+
msgid "'%s' is not a valid date"
|
218
|
+
msgstr "「%s」不是個有效的日期"
|
219
|
+
|
220
|
+
#: lib/hammer_cli/options/normalizers.rb:175
|
221
|
+
msgid "Any combination (comma separated list) of '%s'"
|
222
|
+
msgstr "任何(以逗號隔開的)「%s」的組合"
|
223
|
+
|
224
|
+
#: lib/hammer_cli/options/normalizers.rb:195
|
225
|
+
msgid "value must be a combination of '%s'"
|
226
|
+
msgstr "值必須是「%s」的組合"
|
227
|
+
|
228
|
+
#: lib/hammer_cli/settings.rb:28
|
229
|
+
msgid ""
|
230
|
+
"Warning: location hammer.modules.d is deprecated, move your module "
|
231
|
+
"configurations to cli.modules.d"
|
232
|
+
msgstr "警告:hammer.modules.d 這個位置已淘汰使用,請將您的模組配置移至 cli.modules.d"
|
233
|
+
|
234
|
+
#: lib/hammer_cli/exception_handler.rb:60
|
235
|
+
msgid "Error: %s"
|
236
|
+
msgstr "錯誤:%s"
|
237
|
+
|
238
|
+
#: lib/hammer_cli/exception_handler.rb:66
|
239
|
+
msgid "Error: %{message}"
|
240
|
+
msgstr ""
|
241
|
+
|
242
|
+
#: lib/hammer_cli/exception_handler.rb:67
|
243
|
+
msgid "See: '%{path} --help'"
|
244
|
+
msgstr ""
|
245
|
+
|
246
|
+
#: lib/hammer_cli/exception_handler.rb:84
|
247
|
+
msgid "Invalid username or password"
|
248
|
+
msgstr "無效的使用者名稱或密碼"
|
249
|
+
|
250
|
+
#: lib/hammer_cli/exception_handler.rb:91
|
251
|
+
msgid "Could not load the API description from the server"
|
252
|
+
msgstr ""
|
253
|
+
|
254
|
+
#: lib/hammer_cli/exception_handler.rb:92
|
255
|
+
msgid "is the server down?"
|
256
|
+
msgstr ""
|
257
|
+
|
258
|
+
#: lib/hammer_cli/exception_handler.rb:93
|
259
|
+
msgid ""
|
260
|
+
"was '%s' run on the server when using apipie cache? (typical production "
|
261
|
+
"settings)"
|
262
|
+
msgstr ""
|
263
|
+
|
264
|
+
#: lib/hammer_cli/output/formatters.rb:154
|
265
|
+
msgid "no"
|
266
|
+
msgstr "否"
|
267
|
+
|
268
|
+
#: lib/hammer_cli/output/formatters.rb:154
|
269
|
+
msgid "yes"
|
270
|
+
msgstr "是"
|
271
|
+
|
272
|
+
#: lib/hammer_cli/output/adapter/csv.rb:171
|
273
|
+
msgid "Message"
|
274
|
+
msgstr "訊息"
|
275
|
+
|
276
|
+
#: lib/hammer_cli/output/adapter/csv.rb:175
|
277
|
+
msgid "Id"
|
278
|
+
msgstr "ID"
|
279
|
+
|
280
|
+
#: lib/hammer_cli/output/adapter/csv.rb:180
|
281
|
+
msgid "Name"
|
282
|
+
msgstr "名稱"
|
283
|
+
|
284
|
+
#: lib/hammer_cli/modules.rb:10
|
285
|
+
msgid ""
|
286
|
+
"Legacy configuration of modules detected. Check section about configuration "
|
287
|
+
"in user manual"
|
288
|
+
msgstr "偵測到了舊式的模組配置。請查看使用者指南中的配置部分"
|
289
|
+
|
290
|
+
#: lib/hammer_cli/modules.rb:42
|
291
|
+
msgid "Warning: An error occured while loading module %s"
|
292
|
+
msgstr "警告:載入 %s 模組時發生了錯誤"
|
@@ -113,6 +113,28 @@ describe HammerCLI::Apipie::Command do
|
|
113
113
|
it "should perform a call to api when resource is defined" do
|
114
114
|
cmd_run.must_equal 0
|
115
115
|
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "reload apipie cache" do
|
119
|
+
|
120
|
+
before :each do
|
121
|
+
HammerCLI::Connection.drop_all
|
122
|
+
ApipieBindings::API.any_instance.stubs(:call).returns([])
|
123
|
+
end
|
124
|
+
|
125
|
+
it "clears the cache on init when required from config" do
|
126
|
+
HammerCLI::Settings.load({ :reload_cache => true })
|
127
|
+
ApipieBindings::API.any_instance.expects(:clean_cache).returns(nil)
|
128
|
+
cmd.class.resource :architectures, :index
|
129
|
+
HammerCLI::Settings.load({ :reload_cache => false })
|
130
|
+
end
|
131
|
+
|
132
|
+
it "clears the cache on init when required from CLI" do
|
133
|
+
HammerCLI::Settings.load({ :_params => { :reload_cache => true }})
|
134
|
+
ApipieBindings::API.any_instance.expects(:clean_cache).returns(nil)
|
135
|
+
cmd.class.resource :architectures, :index
|
136
|
+
HammerCLI::Settings.load({ :_params => { :reload_cache => false }})
|
137
|
+
end
|
116
138
|
|
117
139
|
end
|
118
140
|
|
@@ -18,8 +18,9 @@ describe HammerCLI::Apipie::OptionBuilder do
|
|
18
18
|
HammerCLI::I18n.clear
|
19
19
|
end
|
20
20
|
|
21
|
-
let(:
|
22
|
-
let(:
|
21
|
+
let(:resource) {api.resource(:documented)}
|
22
|
+
let(:action) {resource.action(:index)}
|
23
|
+
let(:builder) { HammerCLI::Apipie::OptionBuilder.new(resource, action) }
|
23
24
|
let(:builder_options) { {} }
|
24
25
|
let(:options) { builder.build(builder_options) }
|
25
26
|
|
@@ -45,7 +46,7 @@ describe HammerCLI::Apipie::OptionBuilder do
|
|
45
46
|
|
46
47
|
context "required options" do
|
47
48
|
|
48
|
-
let(:action) {
|
49
|
+
let(:action) {resource.action(:create)}
|
49
50
|
let(:required_options) { builder.build.reject{|opt| !opt.required?} }
|
50
51
|
|
51
52
|
it "should set required flag for the required options" do
|
@@ -60,7 +61,7 @@ describe HammerCLI::Apipie::OptionBuilder do
|
|
60
61
|
|
61
62
|
|
62
63
|
context "with hash params" do
|
63
|
-
let(:action) {
|
64
|
+
let(:action) {resource.action(:create)}
|
64
65
|
|
65
66
|
it "should create options for all parameters except the hash" do
|
66
67
|
options.map(&:attribute_name).sort.must_equal HammerCLI.option_accessor_name("array_param", "name", "provider")
|
@@ -72,18 +73,23 @@ describe HammerCLI::Apipie::OptionBuilder do
|
|
72
73
|
end
|
73
74
|
|
74
75
|
context "setting correct normalizers" do
|
75
|
-
let(:action) {
|
76
|
+
let(:action) {resource.action(:typed_params)}
|
76
77
|
|
77
78
|
it "should set array normalizer" do
|
78
79
|
array_option = options.find {|o| o.attribute_name == HammerCLI.option_accessor_name("array_param") }
|
79
80
|
array_option.value_formatter.class.must_equal HammerCLI::Options::Normalizers::List
|
80
81
|
end
|
81
82
|
|
83
|
+
it "should set boolean normalizer" do
|
84
|
+
boolean_option = options.find {|o| o.attribute_name == HammerCLI.option_accessor_name("boolean_param") }
|
85
|
+
boolean_option.value_formatter.class.must_equal HammerCLI::Options::Normalizers::Bool
|
86
|
+
end
|
87
|
+
|
82
88
|
end
|
83
89
|
|
84
90
|
|
85
91
|
context "filtering options" do
|
86
|
-
let(:action) {
|
92
|
+
let(:action) {resource.action(:create)}
|
87
93
|
|
88
94
|
it "should skip filtered options" do
|
89
95
|
builder_options[:without] = ["provider", "name"]
|
@@ -108,7 +114,7 @@ describe HammerCLI::Apipie::OptionBuilder do
|
|
108
114
|
end
|
109
115
|
|
110
116
|
context "aliasing resources" do
|
111
|
-
let(:action) {
|
117
|
+
let(:action) {resource.action(:action_with_ids)}
|
112
118
|
let(:builder_options) { {:resource_mapping => {:organization => 'company', 'compute_resource' => :compute_provider}} }
|
113
119
|
|
114
120
|
it "renames options" do
|
@@ -128,5 +134,13 @@ describe HammerCLI::Apipie::OptionBuilder do
|
|
128
134
|
|
129
135
|
end
|
130
136
|
|
137
|
+
context "setting referenced resources" do
|
138
|
+
let(:action) {resource.action(:action_with_ids)}
|
139
|
+
|
140
|
+
it "sets referenced resources" do
|
141
|
+
options.map(&:referenced_resource).map(&:to_s).sort.must_equal ["", "compute_resource", "organization", "organization"]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
131
145
|
end
|
132
146
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
# require 'hammer_cli/options/option_definition'
|
4
|
+
|
5
|
+
describe HammerCLI::Apipie::OptionDefinition do
|
6
|
+
|
7
|
+
let(:opt) { HammerCLI::Apipie::OptionDefinition.new("--opt", "OPT", "", :referenced_resource => @referenced_resource) }
|
8
|
+
|
9
|
+
describe "referenced resource" do
|
10
|
+
it "should be nil by default" do
|
11
|
+
opt.referenced_resource.must_equal nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should set referenced resource" do
|
15
|
+
@referenced_resource = "organization"
|
16
|
+
opt.referenced_resource.must_equal "organization"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should convert referenced resource name to string" do
|
20
|
+
@referenced_resource = :organization
|
21
|
+
opt.referenced_resource.must_equal "organization"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -115,6 +115,32 @@
|
|
115
115
|
}
|
116
116
|
],
|
117
117
|
"full_description": ""
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "typed_params",
|
121
|
+
"examples": [],
|
122
|
+
"errors": [],
|
123
|
+
"params": [
|
124
|
+
{
|
125
|
+
"name": "array_param",
|
126
|
+
"allow_null": false,
|
127
|
+
"full_name": "documented[array_param]",
|
128
|
+
"validator": "Must be Array",
|
129
|
+
"expected_type": "array",
|
130
|
+
"description": "",
|
131
|
+
"required": true
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"name": "boolean_param",
|
135
|
+
"allow_null": false,
|
136
|
+
"full_name": "documented[boolean_param]",
|
137
|
+
"validator": "Must be Boolean",
|
138
|
+
"expected_type": "boolean",
|
139
|
+
"description": "",
|
140
|
+
"required": false
|
141
|
+
}
|
142
|
+
],
|
143
|
+
"full_description": ""
|
118
144
|
}
|
119
145
|
]
|
120
146
|
}
|