hammer_cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hammer +16 -9
  3. data/doc/creating_commands.md +20 -0
  4. data/doc/release_notes.md +7 -0
  5. data/lib/hammer_cli/apipie/option_builder.rb +4 -0
  6. data/lib/hammer_cli/options/normalizers.rb +25 -2
  7. data/lib/hammer_cli/options/option_definition.rb +12 -0
  8. data/lib/hammer_cli/version.rb +1 -1
  9. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  10. data/locale/de/hammer-cli.edit.po +8 -7
  11. data/locale/de/hammer-cli.po +19 -4
  12. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  13. data/locale/en/hammer-cli.edit.po +87 -72
  14. data/locale/en/hammer-cli.po +15 -3
  15. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  16. data/locale/en_GB/hammer-cli.po +15 -3
  17. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  18. data/locale/es/hammer-cli.po +19 -4
  19. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  20. data/locale/fr/hammer-cli.po +19 -4
  21. data/locale/hammer-cli.pot +140 -124
  22. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  23. data/locale/it/hammer-cli.po +19 -4
  24. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  25. data/locale/ja/hammer-cli.po +19 -4
  26. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  27. data/locale/ko/hammer-cli.po +19 -4
  28. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  29. data/locale/pt_BR/hammer-cli.po +19 -4
  30. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  31. data/locale/ru/hammer-cli.edit.po +12 -11
  32. data/locale/ru/hammer-cli.po +19 -4
  33. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  34. data/locale/zh_CN/hammer-cli.po +19 -4
  35. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  36. data/locale/zh_TW/hammer-cli.po +19 -4
  37. data/test/unit/apipie/option_builder_test.rb +10 -1
  38. data/test/unit/fixtures/apipie/documented.json +18 -0
  39. data/test/unit/options/normalizers_test.rb +13 -2
  40. data/test/unit/options/option_definition_test.rb +30 -0
  41. metadata +4 -4
Binary file
@@ -5,19 +5,20 @@
5
5
  # Translators:
6
6
  # Automatically generated, 2014
7
7
  # Dominic Cleal <dcleal@redhat.com>, 2014
8
+ # Vladimir Pavlov <v.pavlov@i-teco.ru>, 2015
8
9
  msgid ""
9
10
  msgstr ""
10
11
  "Project-Id-Version: Foreman\n"
11
12
  "Report-Msgid-Bugs-To: \n"
12
13
  "POT-Creation-Date: 2014-12-10 13:50+0100\n"
13
- "PO-Revision-Date: 2015-03-09 14:42+0000\n"
14
- "Last-Translator: Lukáš Zapletal\n"
14
+ "PO-Revision-Date: 2015-07-03 11:00+0000\n"
15
+ "Last-Translator: Vladimir Pavlov <v.pavlov@i-teco.ru>\n"
15
16
  "Language-Team: Russian (http://www.transifex.com/projects/p/foreman/language/ru/)\n"
16
17
  "MIME-Version: 1.0\n"
17
18
  "Content-Type: text/plain; charset=UTF-8\n"
18
19
  "Content-Transfer-Encoding: 8bit\n"
19
20
  "Language: ru\n"
20
- "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
21
+ "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
21
22
 
22
23
  #: lib/hammer_cli/clamp.rb:5
23
24
  msgid "too many arguments"
@@ -133,7 +134,7 @@ msgstr "показать сообщения отладки"
133
134
 
134
135
  #: lib/hammer_cli/main.rb:9
135
136
  msgid "force reload of Apipie cache"
136
- msgstr ""
137
+ msgstr "принудительно перезагрузить кэш Apipie"
137
138
 
138
139
  #: lib/hammer_cli/main.rb:11
139
140
  msgid "path to custom config file"
@@ -197,7 +198,7 @@ msgstr "Предупреждение. Произошла ошибка при з
197
198
 
198
199
  #: lib/hammer_cli/modules.rb:87
199
200
  msgid "Error: Some of the required modules are disabled in configuration: %s "
200
- msgstr ""
201
+ msgstr "Ошибка: некоторые из требуемых модулей выключены в конфигурации: %s"
201
202
 
202
203
  #: lib/hammer_cli/exception_handler.rb:62
203
204
  msgid "Error: %s"
@@ -209,7 +210,7 @@ msgstr "Ошибка: %{message}"
209
210
 
210
211
  #: lib/hammer_cli/exception_handler.rb:69
211
212
  msgid "See: '%{path} --help'"
212
- msgstr ""
213
+ msgstr "Смотри: '%{path} --help'"
213
214
 
214
215
  #: lib/hammer_cli/exception_handler.rb:86
215
216
  msgid "Invalid username or password"
@@ -217,21 +218,21 @@ msgstr "Неверное имя пользователя или пароль"
217
218
 
218
219
  #: lib/hammer_cli/exception_handler.rb:93
219
220
  msgid "Could not load the API description from the server"
220
- msgstr ""
221
+ msgstr "Не удалось загрузить описание API с сервера"
221
222
 
222
223
  #: lib/hammer_cli/exception_handler.rb:94
223
224
  msgid "is the server down?"
224
- msgstr ""
225
+ msgstr "сервер выключен?"
225
226
 
226
227
  #: lib/hammer_cli/exception_handler.rb:95
227
228
  msgid ""
228
229
  "was '%s' run on the server when using apipie cache? (typical production "
229
230
  "settings)"
230
- msgstr ""
231
+ msgstr "'%s' был запущен на сервере когда использовался кэш apipie? (типовая продуктивная настройка)"
231
232
 
232
233
  #: lib/hammer_cli/exception_handler.rb:101
233
234
  msgid "Missing arguments for %s"
234
- msgstr ""
235
+ msgstr "Пропущены аргументы для %s"
235
236
 
236
237
  #: lib/hammer_cli/validator.rb:41
237
238
  msgid "Unknown option name '%s'"
@@ -297,4 +298,4 @@ msgstr "Интерактивная оболочка"
297
298
  msgid ""
298
299
  "can't replace subcommand %<name>s (%<existing_class>s) with %<name>s "
299
300
  "(%<new_class>s)"
300
- msgstr ""
301
+ msgstr "невозможно заменить подкоманду %<name> (%<existing_class>) на %<name> (%<new_class>)"
@@ -7,7 +7,7 @@
7
7
  # Dominic Cleal <dcleal@redhat.com>, 2014
8
8
  msgid ""
9
9
  msgstr ""
10
- "Project-Id-Version: hammer-cli 0.2.0\n"
10
+ "Project-Id-Version: hammer-cli 0.3.0\n"
11
11
  "Report-Msgid-Bugs-To: \n"
12
12
  "PO-Revision-Date: 2014-09-16 09:42+0000\n"
13
13
  "Last-Translator: Dominic Cleal <dcleal@redhat.com>\n"
@@ -103,6 +103,10 @@ msgstr "адрес удаленной системы"
103
103
  msgid "show version"
104
104
  msgstr "показать версию"
105
105
 
106
+ #, fuzzy
107
+ msgid "unknown version"
108
+ msgstr "показать версию"
109
+
106
110
  msgid "Show ids of associated resources"
107
111
  msgstr "Показать идентификаторы связанных ресурсов"
108
112
 
@@ -143,6 +147,9 @@ msgstr "значение должно содержать список пар «
143
147
  msgid "Comma separated list of values."
144
148
  msgstr "Список значений через запятую"
145
149
 
150
+ msgid "numeric value is required"
151
+ msgstr ""
152
+
146
153
  msgid "One of true/false, yes/no, 1/0."
147
154
  msgstr "Может принимать значения: true/false, yes/no, 1/0."
148
155
 
@@ -152,10 +159,15 @@ msgstr "значение может быть равно true/false, yes/no, 1/0"
152
159
  msgid "Unable to parse JSON input"
153
160
  msgstr "Не удалось обработать ввод JSON"
154
161
 
155
- msgid "One of %s"
156
- msgstr "Одно из %s"
162
+ msgid "Possible value(s): %s"
163
+ msgstr ""
157
164
 
158
- msgid "value must be one of '%s'"
165
+ #, fuzzy
166
+ msgid "value must be %s"
167
+ msgstr "может принимать значения «%s»"
168
+
169
+ #, fuzzy
170
+ msgid "value must be one of %s"
159
171
  msgstr "может принимать значения «%s»"
160
172
 
161
173
  msgid "Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format"
@@ -170,6 +182,9 @@ msgstr "Любые комбинации «%s» через запятую"
170
182
  msgid "value must be a combination of '%s'"
171
183
  msgstr "значение должно содержать комбинацию «%s»"
172
184
 
185
+ msgid "\"Warning: Option #{switch} is deprecated. %s\""
186
+ msgstr ""
187
+
173
188
  msgid "Can be specified multiple times. "
174
189
  msgstr "Может быть указан повторно."
175
190
 
Binary file
@@ -6,7 +6,7 @@
6
6
  # Automatically generated, 2014
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: hammer-cli 0.2.0\n"
9
+ "Project-Id-Version: hammer-cli 0.3.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "PO-Revision-Date: 2014-09-16 12:21+0000\n"
12
12
  "Last-Translator: Dominic Cleal <dcleal@redhat.com>\n"
@@ -101,6 +101,10 @@ msgstr "远程系统地址"
101
101
  msgid "show version"
102
102
  msgstr "显示版本"
103
103
 
104
+ #, fuzzy
105
+ msgid "unknown version"
106
+ msgstr "显示版本"
107
+
104
108
  msgid "Show ids of associated resources"
105
109
  msgstr "显示关联资源的 id"
106
110
 
@@ -139,6 +143,9 @@ msgstr "必须使用逗号分开的 key=value 定义该值"
139
143
  msgid "Comma separated list of values."
140
144
  msgstr "逗号分开的数值列表。"
141
145
 
146
+ msgid "numeric value is required"
147
+ msgstr ""
148
+
142
149
  msgid "One of true/false, yes/no, 1/0."
143
150
  msgstr "true/false、yes/no、1/0 之一。"
144
151
 
@@ -148,10 +155,15 @@ msgstr "选项值必须是 true/false、yes/no、1/0 之一"
148
155
  msgid "Unable to parse JSON input"
149
156
  msgstr "无法解析 JSON 输入"
150
157
 
151
- msgid "One of %s"
152
- msgstr "%s 之一"
158
+ msgid "Possible value(s): %s"
159
+ msgstr ""
153
160
 
154
- msgid "value must be one of '%s'"
161
+ #, fuzzy
162
+ msgid "value must be %s"
163
+ msgstr "选项值必须是 '%s' 之一 "
164
+
165
+ #, fuzzy
166
+ msgid "value must be one of %s"
155
167
  msgstr "选项值必须是 '%s' 之一 "
156
168
 
157
169
  msgid "Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format"
@@ -166,6 +178,9 @@ msgstr "'%s' 的任意组合(逗号分开的列表)"
166
178
  msgid "value must be a combination of '%s'"
167
179
  msgstr "选项值必须是 '%s' 组合之一"
168
180
 
181
+ msgid "\"Warning: Option #{switch} is deprecated. %s\""
182
+ msgstr ""
183
+
169
184
  msgid "Can be specified multiple times. "
170
185
  msgstr "可多次指定。"
171
186
 
Binary file
@@ -6,7 +6,7 @@
6
6
  # Automatically generated, 2014
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: hammer-cli 0.2.0\n"
9
+ "Project-Id-Version: hammer-cli 0.3.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "PO-Revision-Date: 2014-09-16 13:21+0000\n"
12
12
  "Last-Translator: Dominic Cleal <dcleal@redhat.com>\n"
@@ -101,6 +101,10 @@ msgstr "遠端系統位址"
101
101
  msgid "show version"
102
102
  msgstr "顯示版本"
103
103
 
104
+ #, fuzzy
105
+ msgid "unknown version"
106
+ msgstr "顯示版本"
107
+
104
108
  msgid "Show ids of associated resources"
105
109
  msgstr "顯示相聯資源的 id"
106
110
 
@@ -139,6 +143,9 @@ msgstr "值必須以一列逗號區隔開的 key=value 來定義"
139
143
  msgid "Comma separated list of values."
140
144
  msgstr "逗號區隔開的值。"
141
145
 
146
+ msgid "numeric value is required"
147
+ msgstr ""
148
+
142
149
  msgid "One of true/false, yes/no, 1/0."
143
150
  msgstr "true/false、yes/no、1/0 之一。"
144
151
 
@@ -148,10 +155,15 @@ msgstr "值必須是 true/false、yes/no、1/0 之一"
148
155
  msgid "Unable to parse JSON input"
149
156
  msgstr "無法叵析 JSON 輸入"
150
157
 
151
- msgid "One of %s"
152
- msgstr "%s 之一"
158
+ msgid "Possible value(s): %s"
159
+ msgstr ""
153
160
 
154
- msgid "value must be one of '%s'"
161
+ #, fuzzy
162
+ msgid "value must be %s"
163
+ msgstr "值必須是「%s」之一"
164
+
165
+ #, fuzzy
166
+ msgid "value must be one of %s"
155
167
  msgstr "值必須是「%s」之一"
156
168
 
157
169
  msgid "Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format"
@@ -166,6 +178,9 @@ msgstr "任何(以逗號隔開的)「%s」的組合"
166
178
  msgid "value must be a combination of '%s'"
167
179
  msgstr "值必須是「%s」的組合"
168
180
 
181
+ msgid "\"Warning: Option #{switch} is deprecated. %s\""
182
+ msgstr ""
183
+
169
184
  msgid "Can be specified multiple times. "
170
185
  msgstr "可指定多次。"
171
186
 
@@ -85,6 +85,16 @@ describe HammerCLI::Apipie::OptionBuilder do
85
85
  boolean_option.value_formatter.class.must_equal HammerCLI::Options::Normalizers::Bool
86
86
  end
87
87
 
88
+ it "should set enum normalizer" do
89
+ enum_option = options.find {|o| o.attribute_name == HammerCLI.option_accessor_name("enum_param") }
90
+ enum_option.value_formatter.class.must_equal HammerCLI::Options::Normalizers::Enum
91
+ enum_option.value_formatter.allowed_values.sort.must_equal ["one", "two", "three"].sort
92
+ end
93
+
94
+ it "should set number normalizer" do
95
+ numeric_option = options.find {|o| o.attribute_name == HammerCLI.option_accessor_name("numeric_param") }
96
+ numeric_option.value_formatter.class.must_equal HammerCLI::Options::Normalizers::Number
97
+ end
88
98
  end
89
99
 
90
100
 
@@ -143,4 +153,3 @@ describe HammerCLI::Apipie::OptionBuilder do
143
153
  end
144
154
 
145
155
  end
146
-
@@ -138,6 +138,24 @@
138
138
  "expected_type": "boolean",
139
139
  "description": "",
140
140
  "required": false
141
+ },
142
+ {
143
+ "name": "enum_param",
144
+ "full_name": "documented[enum_param]",
145
+ "allow_nil": true,
146
+ "validator": "Must be one of: one, two, three.",
147
+ "expected_type": "string",
148
+ "description": "",
149
+ "required": false
150
+ },
151
+ {
152
+ "name": "numeric_param",
153
+ "allow_null": false,
154
+ "full_name": "documented[numeric_param]",
155
+ "validator": "Must be Number",
156
+ "expected_type": "number",
157
+ "description": "",
158
+ "required": false
141
159
  }
142
160
  ],
143
161
  "full_description": ""
@@ -101,6 +101,18 @@ describe HammerCLI::Options::Normalizers do
101
101
  end
102
102
  end
103
103
 
104
+ describe 'number' do
105
+ let(:formatter) { HammerCLI::Options::Normalizers::Number.new }
106
+
107
+ it "should return number on numeric values" do
108
+ formatter.format("1").must_equal 1
109
+ end
110
+
111
+ it "should raise ArgumentError on non-numeric values" do
112
+ proc { formatter.format("a") }.must_raise ArgumentError
113
+ end
114
+ end
115
+
104
116
  describe 'bool' do
105
117
 
106
118
  let(:formatter) { HammerCLI::Options::Normalizers::Bool.new }
@@ -206,7 +218,7 @@ describe HammerCLI::Options::Normalizers do
206
218
  end
207
219
 
208
220
  it "should list allowed values in description" do
209
- formatter.description.must_equal("One of 'a', 'b'")
221
+ formatter.description.must_equal("Possible value(s): 'a', 'b'")
210
222
  end
211
223
 
212
224
  end
@@ -273,4 +285,3 @@ describe HammerCLI::Options::Normalizers do
273
285
  end
274
286
 
275
287
  end
276
-
@@ -18,6 +18,16 @@ describe HammerCLI::Options::OptionDefinition do
18
18
  :context_target => :test_option
19
19
  end
20
20
 
21
+ class TestDeprecatedOptionCmd < HammerCLI::AbstractCommand
22
+ option ["--test-option", "--deprecated"], "TEST_OPTION", "Test option",
23
+ :context_target => :test_option,
24
+ :deprecated => { "--deprecated" => "Use --test-option instead" }
25
+ option "--another-deprecated", "OLD_OPTION", "Test old option",
26
+ :context_target => :old_option,
27
+ :deprecated => "It is going to be removed"
28
+ end
29
+
30
+
21
31
  describe "formatters" do
22
32
 
23
33
  it "should use formatter to format a default value" do
@@ -41,6 +51,26 @@ describe HammerCLI::Options::OptionDefinition do
41
51
  end
42
52
  end
43
53
 
54
+ describe "deprecated options" do
55
+ it "prints deprecation warning" do
56
+ context = {}
57
+ cmd = TestDeprecatedOptionCmd.new("", context)
58
+
59
+ out, err = capture_io { cmd.run(["--another-deprecated=VALUE"]) }
60
+ err.must_match /Warning: Option --another-deprecated is deprecated. It is going to be removed/
61
+ context[:old_option].must_equal "VALUE"
62
+ end
63
+
64
+ it "prints deprecation warning (extended version)" do
65
+ context = {}
66
+ cmd = TestDeprecatedOptionCmd.new("", context)
67
+
68
+ out, err = capture_io { cmd.run(["--deprecated=VALUE"]) }
69
+ err.must_match /Warning: Option --deprecated is deprecated. Use --test-option instead/
70
+ context[:test_option].must_equal "VALUE"
71
+ end
72
+ end
73
+
44
74
  describe "context" do
45
75
  it "should save option to context" do
46
76
  context = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bačovský
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-23 00:00:00.000000000 Z
12
+ date: 2015-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: 1.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '>='
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: 1.0.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rest-client
30
30
  requirement: !ruby/object:Gem::Requirement