hammer_cli 3.7.0 → 3.8.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.
- checksums.yaml +4 -4
- data/bin/hammer +1 -6
- data/doc/release_notes.md +15 -0
- data/lib/hammer_cli/help/builder.rb +1 -2
- data/lib/hammer_cli/i18n/find_task.rb +88 -0
- data/lib/hammer_cli/i18n.rb +4 -0
- data/lib/hammer_cli/options/normalizers.rb +2 -5
- data/lib/hammer_cli/settings.rb +7 -0
- data/lib/hammer_cli/task_helper.rb +84 -0
- data/lib/hammer_cli/testing/output_matchers.rb +1 -1
- data/lib/hammer_cli/utils.rb +1 -1
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/Makefile.def +29 -7
- data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/cs_CZ/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ka/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/man/hammer.1.gz +0 -0
- data/test/functional/help_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/abstract_test.rb +54 -54
- data/test/unit/apipie/command_test.rb +26 -27
- data/test/unit/apipie/option_builder_test.rb +28 -28
- data/test/unit/apipie/option_definition_test.rb +5 -5
- data/test/unit/apipie/test_helper.rb +3 -0
- data/test/unit/bash_test.rb +21 -21
- data/test/unit/command_extensions_test.rb +68 -68
- data/test/unit/completer_test.rb +57 -57
- data/test/unit/csv_parser_test.rb +12 -12
- data/test/unit/defaults_test.rb +3 -3
- data/test/unit/help/builder_test.rb +7 -7
- data/test/unit/help/definition/abstract_item_test.rb +2 -2
- data/test/unit/help/definition/list_test.rb +2 -2
- data/test/unit/help/definition/note_test.rb +2 -2
- data/test/unit/help/definition/section_test.rb +2 -2
- data/test/unit/help/definition/text_test.rb +2 -2
- data/test/unit/help/definition_test.rb +36 -36
- data/test/unit/help/text_builder_test.rb +39 -39
- data/test/unit/history_test.rb +6 -6
- data/test/unit/i18n_test.rb +2 -2
- data/test/unit/logger_test.rb +1 -1
- data/test/unit/main_test.rb +7 -7
- data/test/unit/modules_test.rb +24 -25
- data/test/unit/option_builder_test.rb +1 -1
- data/test/unit/options/matcher_test.rb +15 -15
- data/test/unit/options/normalizers_test.rb +92 -88
- data/test/unit/options/option_definition_test.rb +11 -11
- data/test/unit/options/option_family_test.rb +7 -7
- data/test/unit/options/validators/dsl_test.rb +35 -35
- data/test/unit/output/adapter/abstract_test.rb +10 -10
- data/test/unit/output/adapter/base_test.rb +36 -36
- data/test/unit/output/adapter/csv_test.rb +38 -38
- data/test/unit/output/adapter/json_test.rb +38 -38
- data/test/unit/output/adapter/table_test.rb +42 -50
- data/test/unit/output/adapter/yaml_test.rb +38 -38
- data/test/unit/output/definition_test.rb +43 -43
- data/test/unit/output/dsl_test.rb +19 -19
- data/test/unit/output/field_filter_test.rb +10 -10
- data/test/unit/output/fields_test.rb +27 -27
- data/test/unit/output/formatters_test.rb +39 -39
- data/test/unit/output/output_test.rb +14 -14
- data/test/unit/output/record_collection_test.rb +18 -18
- data/test/unit/settings_test.rb +35 -35
- data/test/unit/utils_test.rb +30 -27
- metadata +33 -44
data/test/unit/completer_test.rb
CHANGED
@@ -8,81 +8,81 @@ describe HammerCLI::CompleterWord do
|
|
8
8
|
describe "quote" do
|
9
9
|
it "returns empty string for empty word" do
|
10
10
|
word = HammerCLI::CompleterWord.new('')
|
11
|
-
word.quote.must_equal ""
|
11
|
+
_(word.quote).must_equal ""
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns empty string for word without quotes" do
|
15
15
|
word = HammerCLI::CompleterWord.new('word')
|
16
|
-
word.quote.must_equal ""
|
16
|
+
_(word.quote).must_equal ""
|
17
17
|
end
|
18
18
|
|
19
19
|
it "recognizes double quotes" do
|
20
20
|
word = HammerCLI::CompleterWord.new('"word')
|
21
|
-
word.quote.must_equal '"'
|
21
|
+
_(word.quote).must_equal '"'
|
22
22
|
end
|
23
23
|
|
24
24
|
it "recognizes single quotes" do
|
25
25
|
word = HammerCLI::CompleterWord.new('\'word')
|
26
|
-
word.quote.must_equal "'"
|
26
|
+
_(word.quote).must_equal "'"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "quoted?" do
|
31
31
|
it "returns false for an unquoted word" do
|
32
32
|
word = HammerCLI::CompleterWord.new('word')
|
33
|
-
word.quoted
|
33
|
+
_(word.quoted?).must_equal false
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns true for double quotes" do
|
37
37
|
word = HammerCLI::CompleterWord.new('"word')
|
38
|
-
word.quoted
|
38
|
+
_(word.quoted?).must_equal true
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns true for single quotes" do
|
42
42
|
word = HammerCLI::CompleterWord.new('\'word')
|
43
|
-
word.quoted
|
43
|
+
_(word.quoted?).must_equal true
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "complete?" do
|
48
48
|
it "considers a word without quotes complete" do
|
49
49
|
word = HammerCLI::CompleterWord.new('word')
|
50
|
-
word.complete
|
50
|
+
_(word.complete?).must_equal false
|
51
51
|
end
|
52
52
|
|
53
53
|
it "considers a word without quotes ending with space incomplete" do
|
54
54
|
word = HammerCLI::CompleterWord.new('word ')
|
55
|
-
word.complete
|
55
|
+
_(word.complete?).must_equal true
|
56
56
|
end
|
57
57
|
|
58
58
|
it "considers open double quotes incomplete" do
|
59
59
|
word = HammerCLI::CompleterWord.new('"word')
|
60
|
-
word.complete
|
60
|
+
_(word.complete?).must_equal false
|
61
61
|
end
|
62
62
|
|
63
63
|
it "considers open double quotes with spaces incomplete" do
|
64
64
|
word = HammerCLI::CompleterWord.new('"word ')
|
65
|
-
word.complete
|
65
|
+
_(word.complete?).must_equal false
|
66
66
|
end
|
67
67
|
|
68
68
|
it "considers closed double quotes complete" do
|
69
69
|
word = HammerCLI::CompleterWord.new('"word"')
|
70
|
-
word.complete
|
70
|
+
_(word.complete?).must_equal true
|
71
71
|
end
|
72
72
|
|
73
73
|
it "considers open single quotes incomplete" do
|
74
74
|
word = HammerCLI::CompleterWord.new('\'word')
|
75
|
-
word.complete
|
75
|
+
_(word.complete?).must_equal false
|
76
76
|
end
|
77
77
|
|
78
78
|
it "considers open single quotes with spaces incomplete" do
|
79
79
|
word = HammerCLI::CompleterWord.new('\'word ')
|
80
|
-
word.complete
|
80
|
+
_(word.complete?).must_equal false
|
81
81
|
end
|
82
82
|
|
83
83
|
it "considers closed single quotes complete" do
|
84
84
|
word = HammerCLI::CompleterWord.new('\'word\'')
|
85
|
-
word.complete
|
85
|
+
_(word.complete?).must_equal true
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -94,57 +94,57 @@ describe HammerCLI::CompleterLine do
|
|
94
94
|
|
95
95
|
it "should split basic line" do
|
96
96
|
line = HammerCLI::CompleterLine.new("architecture list --name arch")
|
97
|
-
line.must_equal ["architecture", "list", "--name", "arch"]
|
97
|
+
_(line).must_equal ["architecture", "list", "--name", "arch"]
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should split basic line with space at the end" do
|
101
101
|
line = HammerCLI::CompleterLine.new("architecture list --name arch ")
|
102
|
-
line.must_equal ["architecture", "list", "--name", "arch"]
|
102
|
+
_(line).must_equal ["architecture", "list", "--name", "arch"]
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should split on equal sign" do
|
106
106
|
line = HammerCLI::CompleterLine.new("--name=arch")
|
107
|
-
line.must_equal ["--name", "arch"]
|
107
|
+
_(line).must_equal ["--name", "arch"]
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should split when last character is equal sign" do
|
111
111
|
line = HammerCLI::CompleterLine.new("--name=")
|
112
|
-
line.must_equal ["--name"]
|
112
|
+
_(line).must_equal ["--name"]
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should split on equal sign when quotes are used" do
|
116
116
|
line = HammerCLI::CompleterLine.new("--name='arch' ")
|
117
|
-
line.must_equal ["--name", "arch"]
|
117
|
+
_(line).must_equal ["--name", "arch"]
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should split line with single quotes" do
|
121
121
|
line = HammerCLI::CompleterLine.new("--name 'arch' ")
|
122
|
-
line.must_equal ["--name", "arch"]
|
122
|
+
_(line).must_equal ["--name", "arch"]
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should split line with double quotes" do
|
126
126
|
line = HammerCLI::CompleterLine.new("--name \"arch\"")
|
127
|
-
line.must_equal ["--name", "arch"]
|
127
|
+
_(line).must_equal ["--name", "arch"]
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should split line with single quotes and space between" do
|
131
131
|
line = HammerCLI::CompleterLine.new("--name 'ar ch '")
|
132
|
-
line.must_equal ["--name", "ar ch "]
|
132
|
+
_(line).must_equal ["--name", "ar ch "]
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should split line with one single quote and space between" do
|
136
136
|
line = HammerCLI::CompleterLine.new("--name 'ar ch ")
|
137
|
-
line.must_equal ["--name", "ar ch "]
|
137
|
+
_(line).must_equal ["--name", "ar ch "]
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should split line with double quotes and space between" do
|
141
141
|
line = HammerCLI::CompleterLine.new("--name \"ar ch \"")
|
142
|
-
line.must_equal ["--name", "ar ch "]
|
142
|
+
_(line).must_equal ["--name", "ar ch "]
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should split line with one double quote and space between" do
|
146
146
|
line = HammerCLI::CompleterLine.new("--name \"ar ch ")
|
147
|
-
line.must_equal ["--name", "ar ch "]
|
147
|
+
_(line).must_equal ["--name", "ar ch "]
|
148
148
|
end
|
149
149
|
|
150
150
|
end
|
@@ -153,47 +153,47 @@ describe HammerCLI::CompleterLine do
|
|
153
153
|
|
154
154
|
it "should recongize incomplete line" do
|
155
155
|
line = HammerCLI::CompleterLine.new("architecture list --name arch")
|
156
|
-
line.complete
|
156
|
+
_(line.complete?).must_equal false
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should recongize complete line" do
|
160
160
|
line = HammerCLI::CompleterLine.new("architecture list --name arch ")
|
161
|
-
line.complete
|
161
|
+
_(line.complete?).must_equal true
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should recongize complete line that ends with quotes" do
|
165
165
|
line = HammerCLI::CompleterLine.new("--name 'ar ch'")
|
166
|
-
line.complete
|
166
|
+
_(line.complete?).must_equal true
|
167
167
|
end
|
168
168
|
|
169
169
|
it "should recongize complete line that ends with quotes followed by space" do
|
170
170
|
line = HammerCLI::CompleterLine.new("--name 'ar ch' ")
|
171
|
-
line.complete
|
171
|
+
_(line.complete?).must_equal true
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should recongize complete line that ends with double quotes" do
|
175
175
|
line = HammerCLI::CompleterLine.new("--name \"ar ch\"")
|
176
|
-
line.complete
|
176
|
+
_(line.complete?).must_equal true
|
177
177
|
end
|
178
178
|
|
179
179
|
it "should recongize one quote as incomplete" do
|
180
180
|
line = HammerCLI::CompleterLine.new("--name '")
|
181
|
-
line.complete
|
181
|
+
_(line.complete?).must_equal false
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should recongize one quote followed by space as incomplete" do
|
185
185
|
line = HammerCLI::CompleterLine.new("--name ' ")
|
186
|
-
line.complete
|
186
|
+
_(line.complete?).must_equal false
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should recongize one double quote as incomplete" do
|
190
190
|
line = HammerCLI::CompleterLine.new("--name \"")
|
191
|
-
line.complete
|
191
|
+
_(line.complete?).must_equal false
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should recongize empty line as complete" do
|
195
195
|
line = HammerCLI::CompleterLine.new("")
|
196
|
-
line.complete
|
196
|
+
_(line.complete?).must_equal true
|
197
197
|
end
|
198
198
|
|
199
199
|
end
|
@@ -265,97 +265,97 @@ describe HammerCLI::Completer do
|
|
265
265
|
let(:ape_completions) { ["makkak ", "malpa ", "orangutan ", "--hairy ", "--weight ", "--height ", "-h ", "--help "] }
|
266
266
|
|
267
267
|
it "should offer all available commands" do
|
268
|
-
completer.complete("").sort.must_equal ["anabolic ", "ape ", "apocalypse ", "beast ", "-h ", "--help "].sort
|
268
|
+
_(completer.complete("").sort).must_equal ["anabolic ", "ape ", "apocalypse ", "beast ", "-h ", "--help "].sort
|
269
269
|
end
|
270
270
|
|
271
271
|
it "should offer nothing when the line does not match" do
|
272
|
-
completer.complete("x").must_equal []
|
272
|
+
_(completer.complete("x")).must_equal []
|
273
273
|
end
|
274
274
|
|
275
275
|
it "should filter by first letter" do
|
276
|
-
completer.complete("a").sort.must_equal ["anabolic ", "ape ", "apocalypse "].sort
|
276
|
+
_(completer.complete("a").sort).must_equal ["anabolic ", "ape ", "apocalypse "].sort
|
277
277
|
end
|
278
278
|
|
279
279
|
it "should filter by first two letters" do
|
280
|
-
completer.complete("ap").sort.must_equal ["ape ", "apocalypse "].sort
|
280
|
+
_(completer.complete("ap").sort).must_equal ["ape ", "apocalypse "].sort
|
281
281
|
end
|
282
282
|
|
283
283
|
it "should offer all available subcommands and options" do
|
284
|
-
completer.complete("ape ").sort.must_equal ape_completions.sort
|
284
|
+
_(completer.complete("ape ").sort).must_equal ape_completions.sort
|
285
285
|
end
|
286
286
|
|
287
287
|
it "should offer all available subcommands and options even if a flag has been passed" do
|
288
|
-
completer.complete("ape --hairy ").sort.must_equal ape_completions.sort
|
288
|
+
_(completer.complete("ape --hairy ").sort).must_equal ape_completions.sort
|
289
289
|
end
|
290
290
|
|
291
291
|
it "should offer all available subcommands and options even if an option has been passed" do
|
292
|
-
completer.complete("ape --weight 12kg ").sort.must_equal ape_completions.sort
|
292
|
+
_(completer.complete("ape --weight 12kg ").sort).must_equal ape_completions.sort
|
293
293
|
end
|
294
294
|
|
295
295
|
it "should offer all available subcommands and options even if an egual sign option has been passed" do
|
296
|
-
completer.complete("ape --weight=12kg ").sort.must_equal ape_completions.sort
|
296
|
+
_(completer.complete("ape --weight=12kg ").sort).must_equal ape_completions.sort
|
297
297
|
end
|
298
298
|
|
299
299
|
it "should offer all available subcommands and options when quoted value was passed" do
|
300
|
-
completer.complete("ape --weight '12 kg' ").sort.must_equal ape_completions.sort
|
300
|
+
_(completer.complete("ape --weight '12 kg' ").sort).must_equal ape_completions.sort
|
301
301
|
end
|
302
302
|
|
303
303
|
it "should offer all available subcommands and options when double quoted value was passed" do
|
304
|
-
completer.complete("ape --weight \"12 kg\" ").sort.must_equal ape_completions.sort
|
304
|
+
_(completer.complete("ape --weight \"12 kg\" ").sort).must_equal ape_completions.sort
|
305
305
|
end
|
306
306
|
|
307
307
|
it "should offer all available subcommands and options when quoted value with equal sign was passed" do
|
308
|
-
completer.complete("ape --weight='12 kg' ").sort.must_equal ape_completions.sort
|
308
|
+
_(completer.complete("ape --weight='12 kg' ").sort).must_equal ape_completions.sort
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
312
|
|
313
313
|
context "option value completion" do
|
314
314
|
it "should complete option values" do
|
315
|
-
completer.complete("ape --height ").sort.must_equal ["small ", "tall ", "smel ly"].sort
|
315
|
+
_(completer.complete("ape --height ").sort).must_equal ["small ", "tall ", "smel ly"].sort
|
316
316
|
end
|
317
317
|
|
318
318
|
it "should complete option values when equal sign is used" do
|
319
|
-
completer.complete("ape --height=").sort.must_equal ["small ", "tall ", "smel ly"].sort
|
319
|
+
_(completer.complete("ape --height=").sort).must_equal ["small ", "tall ", "smel ly"].sort
|
320
320
|
end
|
321
321
|
|
322
322
|
it "should complete option values" do
|
323
|
-
completer.complete("ape --height s").must_equal ["small ", "smel ly"]
|
323
|
+
_(completer.complete("ape --height s")).must_equal ["small ", "smel ly"]
|
324
324
|
end
|
325
325
|
|
326
326
|
it "should complete quoted option values" do
|
327
|
-
completer.complete("ape --height 's").must_equal ["'small' ", "'smel ly"]
|
327
|
+
_(completer.complete("ape --height 's")).must_equal ["'small' ", "'smel ly"]
|
328
328
|
end
|
329
329
|
|
330
330
|
it "should complete quoted option values" do
|
331
|
-
completer.complete("ape --height 'smel l").must_equal ["'smel ly"]
|
331
|
+
_(completer.complete("ape --height 'smel l")).must_equal ["'smel ly"]
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
335
|
|
336
336
|
context "subcommand completion" do
|
337
337
|
it "should filter subcommands by first letter" do
|
338
|
-
completer.complete("ape m").sort.must_equal ["makkak ", "malpa "].sort
|
338
|
+
_(completer.complete("ape m").sort).must_equal ["makkak ", "malpa "].sort
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should offer nothing when the line does not match any subcommand" do
|
342
|
-
completer.complete("ape x").must_equal []
|
342
|
+
_(completer.complete("ape x")).must_equal []
|
343
343
|
end
|
344
344
|
|
345
345
|
it "should ignore flags specified before the last command" do
|
346
|
-
completer.complete("ape --hairy m").sort.must_equal ["makkak ", "malpa "].sort
|
346
|
+
_(completer.complete("ape --hairy m").sort).must_equal ["makkak ", "malpa "].sort
|
347
347
|
end
|
348
348
|
|
349
349
|
it "should ignore options specified before the last command" do
|
350
|
-
completer.complete("ape --weight 12kg m").sort.must_equal ["makkak ", "malpa "].sort
|
350
|
+
_(completer.complete("ape --weight 12kg m").sort).must_equal ["makkak ", "malpa "].sort
|
351
351
|
end
|
352
352
|
|
353
353
|
it "should ignore equal sign separated options specified before the last command" do
|
354
|
-
completer.complete("ape --weight=12kg m").sort.must_equal ["makkak ", "malpa "].sort
|
354
|
+
_(completer.complete("ape --weight=12kg m").sort).must_equal ["makkak ", "malpa "].sort
|
355
355
|
end
|
356
356
|
|
357
357
|
it "should filter subcommands by first three letters" do
|
358
|
-
completer.complete("ape mak").must_equal ["makkak "]
|
358
|
+
_(completer.complete("ape mak")).must_equal ["makkak "]
|
359
359
|
end
|
360
360
|
end
|
361
361
|
|
@@ -7,48 +7,48 @@ describe HammerCLI::CSVParser do
|
|
7
7
|
let(:parser) { HammerCLI::CSVParser.new }
|
8
8
|
|
9
9
|
it "parses nil" do
|
10
|
-
parser.parse(nil).must_equal []
|
10
|
+
_(parser.parse(nil)).must_equal []
|
11
11
|
end
|
12
12
|
|
13
13
|
it "parses empty string" do
|
14
|
-
parser.parse('').must_equal ['']
|
14
|
+
_(parser.parse('')).must_equal ['']
|
15
15
|
end
|
16
16
|
|
17
17
|
it "parses single value" do
|
18
|
-
parser.parse('a').must_equal ['a']
|
18
|
+
_(parser.parse('a')).must_equal ['a']
|
19
19
|
end
|
20
20
|
|
21
21
|
it "parses a dquoted string" do
|
22
|
-
parser.parse('\"a').must_equal ['"a']
|
22
|
+
_(parser.parse('\"a')).must_equal ['"a']
|
23
23
|
end
|
24
24
|
|
25
25
|
it "parses a quoted string" do
|
26
|
-
parser.parse("Mary\\'s").must_equal ["Mary's"]
|
26
|
+
_(parser.parse("Mary\\'s")).must_equal ["Mary's"]
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should parse a comma separated string" do
|
30
|
-
parser.parse("a,b,c").must_equal ['a', 'b', 'c']
|
30
|
+
_(parser.parse("a,b,c")).must_equal ['a', 'b', 'c']
|
31
31
|
end
|
32
32
|
|
33
33
|
it "parses a string with escaped comma" do
|
34
|
-
parser.parse('a\,b,c').must_equal ['a,b', 'c']
|
34
|
+
_(parser.parse('a\,b,c')).must_equal ['a,b', 'c']
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should parse a comma separated string with quotes" do
|
38
|
-
parser.parse('a,b,\\"c\\"').must_equal ['a', 'b', '"c"']
|
38
|
+
_(parser.parse('a,b,\\"c\\"')).must_equal ['a', 'b', '"c"']
|
39
39
|
end
|
40
40
|
|
41
41
|
it "parses a comma separated string with values including comma" do
|
42
|
-
parser.parse('a,b,"c,d"').must_equal ['a', 'b', 'c,d']
|
42
|
+
_(parser.parse('a,b,"c,d"')).must_equal ['a', 'b', 'c,d']
|
43
43
|
end
|
44
44
|
|
45
45
|
it "parses a comma separated string with values including comma (dquotes)" do
|
46
|
-
parser.parse("a,b,'c,d'").must_equal ['a', 'b', 'c,d']
|
46
|
+
_(parser.parse("a,b,'c,d'")).must_equal ['a', 'b', 'c,d']
|
47
47
|
end
|
48
48
|
|
49
49
|
it "raises quoting error" do
|
50
|
-
err =
|
51
|
-
err.message.must_equal "Illegal quoting in \"3,4\"\"s"
|
50
|
+
err = _{ parser.parse('1,"3,4""s') }.must_raise ArgumentError
|
51
|
+
_(err.message).must_equal "Illegal quoting in \"3,4\"\"s"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
data/test/unit/defaults_test.rb
CHANGED
@@ -26,7 +26,7 @@ describe HammerCLI::Defaults do
|
|
26
26
|
it "Should update dashed default when underscored default is set" do
|
27
27
|
defaults_result = @defaults.add_defaults_to_conf({"location-id"=> 3}, nil)
|
28
28
|
assert_equal '3', defaults_result[:defaults][:'location-id'][:value]
|
29
|
-
|
29
|
+
assert_nil defaults_result[:defaults][:location_id]
|
30
30
|
end
|
31
31
|
|
32
32
|
context "dashed" do
|
@@ -34,13 +34,13 @@ describe HammerCLI::Defaults do
|
|
34
34
|
it "Should update underscored default when dashed default is set" do
|
35
35
|
defaults_result = @defaults.add_defaults_to_conf({"location_id"=> 3}, nil)
|
36
36
|
assert_equal '3', defaults_result[:defaults][:location_id][:value]
|
37
|
-
|
37
|
+
assert_nil defaults_result[:defaults][:'location-id']
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should update underscored default with option syntax when dashed default is set" do
|
41
41
|
defaults_result = @defaults.add_defaults_to_conf({"--location-id"=> 3}, nil)
|
42
42
|
assert_equal '3', defaults_result[:defaults][:'location-id'][:value]
|
43
|
-
|
43
|
+
assert_nil defaults_result[:defaults][:location_id]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -13,7 +13,7 @@ describe HammerCLI::Help::Builder do
|
|
13
13
|
]
|
14
14
|
help.add_list('Options', options)
|
15
15
|
|
16
|
-
help.string.strip.must_equal [
|
16
|
+
_(help.string.strip).must_equal [
|
17
17
|
'Options:',
|
18
18
|
' --aaa-option OPT_A Some description',
|
19
19
|
' --bbb-option OPT_B Some description',
|
@@ -31,7 +31,7 @@ describe HammerCLI::Help::Builder do
|
|
31
31
|
]
|
32
32
|
help.add_list('Options', options)
|
33
33
|
|
34
|
-
help.string.strip.must_equal [
|
34
|
+
_(help.string.strip).must_equal [
|
35
35
|
'Options:',
|
36
36
|
' --aaa-option OPT_A %s' % ('AAAAAAA ' * 10).strip,
|
37
37
|
' %s' % ('AAAAAAA ' * 10).strip,
|
@@ -49,7 +49,7 @@ describe HammerCLI::Help::Builder do
|
|
49
49
|
]
|
50
50
|
help.add_list('Options',options)
|
51
51
|
|
52
|
-
help.string.strip.must_equal [
|
52
|
+
_(help.string.strip).must_equal [
|
53
53
|
'Options:',
|
54
54
|
' --alpha-option OPT_ALPHA Alpha description',
|
55
55
|
' --beta-option OPT_BETA BETA description'
|
@@ -69,12 +69,12 @@ describe HammerCLI::Help::Builder do
|
|
69
69
|
|
70
70
|
it 'prints paragraphs without headings' do
|
71
71
|
help.add_text(content_1.join("\n"))
|
72
|
-
help.string.strip.must_equal content_1.join("\n")
|
72
|
+
_(help.string.strip).must_equal content_1.join("\n")
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'prints paragraphs with headings' do
|
76
76
|
help.add_text(content_1.join("\n"))
|
77
|
-
help.string.strip.must_equal content_1.join("\n")
|
77
|
+
_(help.string.strip).must_equal content_1.join("\n")
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'prints multiple paragraphs divided with empty line' do
|
@@ -84,7 +84,7 @@ describe HammerCLI::Help::Builder do
|
|
84
84
|
expected_output = content_1 + [''] + content_2
|
85
85
|
expected_output = expected_output.join("\n")
|
86
86
|
|
87
|
-
help.string.strip.must_equal expected_output
|
87
|
+
_(help.string.strip).must_equal expected_output
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -102,7 +102,7 @@ describe HammerCLI::Help::Builder do
|
|
102
102
|
options = fm1.all + fm2.all
|
103
103
|
help.add_list('Options', options)
|
104
104
|
|
105
|
-
help.string.strip.must_equal [
|
105
|
+
_(help.string.strip).must_equal [
|
106
106
|
'Options:',
|
107
107
|
' --option[-yyy|-bbb] VALUE Some description',
|
108
108
|
' --option[-aaa|-zzz] VALUE Some description'
|
@@ -15,7 +15,7 @@ describe HammerCLI::Help::AbstractItem do
|
|
15
15
|
' Dolor sit amet',
|
16
16
|
''
|
17
17
|
].join("\n")
|
18
|
-
section.build_string.must_equal(expected_result)
|
18
|
+
_(section.build_string).must_equal(expected_result)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'indents text with custom padding' do
|
@@ -27,7 +27,7 @@ describe HammerCLI::Help::AbstractItem do
|
|
27
27
|
'** Dolor sit amet',
|
28
28
|
''
|
29
29
|
].join("\n")
|
30
|
-
section.build_string.must_equal(expected_result)
|
30
|
+
_(section.build_string).must_equal(expected_result)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -8,7 +8,7 @@ describe HammerCLI::Help::List do
|
|
8
8
|
let(:item_with_options) { [:third, 'This is bold item', { bold: true }] }
|
9
9
|
|
10
10
|
it 'builds string' do
|
11
|
-
list.build_string.must_equal [
|
11
|
+
_(list.build_string).must_equal [
|
12
12
|
'first This is first line',
|
13
13
|
'second This is second line',
|
14
14
|
''
|
@@ -18,7 +18,7 @@ describe HammerCLI::Help::List do
|
|
18
18
|
it 'ensures that item options are used' do
|
19
19
|
list = HammerCLI::Help::List.new([first_item, second_item, item_with_options])
|
20
20
|
changed_item = HighLine.color('third', :bold)
|
21
|
-
list.build_string.must_equal [
|
21
|
+
_(list.build_string).must_equal [
|
22
22
|
'first This is first line',
|
23
23
|
'second This is second line',
|
24
24
|
"#{changed_item} This is bold item",
|
@@ -6,13 +6,13 @@ describe HammerCLI::Help::Note do
|
|
6
6
|
let(:note) { HammerCLI::Help::Note.new(text) }
|
7
7
|
|
8
8
|
it 'builds string' do
|
9
|
-
note.build_string.must_equal 'NOTE: text'
|
9
|
+
_(note.build_string).must_equal 'NOTE: text'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'ensures that options are used' do
|
13
13
|
label = 'DEPRECATION'
|
14
14
|
note = HammerCLI::Help::Note.new(text, label: label, richtext: true)
|
15
|
-
note.build_string.must_equal "#{HighLine.color("#{label}:", :bold)} #{text}"
|
15
|
+
_(note.build_string).must_equal "#{HighLine.color("#{label}:", :bold)} #{text}"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -7,7 +7,7 @@ describe HammerCLI::Help::Section do
|
|
7
7
|
let(:second_text) { HammerCLI::Help::Text.new('second') }
|
8
8
|
|
9
9
|
it 'builds string without definition' do
|
10
|
-
section.build_string.must_equal "section:\n\n"
|
10
|
+
_(section.build_string).must_equal "section:\n\n"
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'builds string with definition' do
|
@@ -19,7 +19,7 @@ describe HammerCLI::Help::Section do
|
|
19
19
|
' second',
|
20
20
|
''
|
21
21
|
].join("\n")
|
22
|
-
section.build_string.must_equal expected_output
|
22
|
+
_(section.build_string).must_equal expected_output
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,12 +5,12 @@ describe HammerCLI::Help::Text do
|
|
5
5
|
let(:text) { HammerCLI::Help::Text.new('text') }
|
6
6
|
|
7
7
|
it 'builds string' do
|
8
|
-
text.build_string.must_equal 'text'
|
8
|
+
_(text.build_string).must_equal 'text'
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'ensures that options are used' do
|
12
12
|
text = HammerCLI::Help::Text.new('text', richtext: true)
|
13
|
-
text.build_string.must_equal HighLine.color('text', :bold)
|
13
|
+
_(text.build_string).must_equal HighLine.color('text', :bold)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|