hammer_cli 2.5.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hammer +1 -1
- data/doc/commands_extension.md +8 -6
- data/doc/creating_commands.md +17 -0
- data/doc/release_notes.md +23 -0
- data/lib/hammer_cli/abstract.rb +75 -60
- data/lib/hammer_cli/apipie/command.rb +1 -1
- data/lib/hammer_cli/apipie/option_builder.rb +16 -11
- data/lib/hammer_cli/apipie/option_definition.rb +1 -8
- data/lib/hammer_cli/command_extensions.rb +47 -34
- data/lib/hammer_cli/help/builder.rb +10 -6
- data/lib/hammer_cli/options/normalizers.rb +126 -18
- data/lib/hammer_cli/options/option_definition.rb +17 -22
- data/lib/hammer_cli/options/option_family.rb +44 -8
- data/lib/hammer_cli/output/adapter/abstract.rb +6 -0
- data/lib/hammer_cli/output/adapter/base.rb +1 -1
- data/lib/hammer_cli/output/adapter/tree_structure.rb +1 -1
- data/lib/hammer_cli/output/definition.rb +1 -1
- data/lib/hammer_cli/output/field_filter.rb +2 -2
- data/lib/hammer_cli/utils.rb +6 -0
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/ca/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/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/unit/abstract_test.rb +7 -0
- data/test/unit/apipie/option_builder_test.rb +8 -3
- data/test/unit/command_extensions_test.rb +10 -2
- data/test/unit/help/builder_test.rb +20 -2
- data/test/unit/options/option_definition_test.rb +12 -1
- data/test/unit/output/definition_test.rb +3 -3
- metadata +22 -22
@@ -21,6 +21,24 @@ describe HammerCLI::Help::Builder do
|
|
21
21
|
' --zzz-option OPT_Z Some description'
|
22
22
|
].join("\n")
|
23
23
|
end
|
24
|
+
|
25
|
+
it 'prints long option descriptions aligned' do
|
26
|
+
opt_a_desc = 'AAAAAAA ' * 20
|
27
|
+
opt_b_desc = 'BBBBBBB ' * 20
|
28
|
+
options = [
|
29
|
+
Clamp::Option::Definition.new(['--aaa-option'], 'OPT_A', opt_a_desc),
|
30
|
+
Clamp::Option::Definition.new(['--bbb-option'], 'OPT_B', opt_b_desc)
|
31
|
+
]
|
32
|
+
help.add_list('Options', options)
|
33
|
+
|
34
|
+
help.string.strip.must_equal [
|
35
|
+
'Options:',
|
36
|
+
' --aaa-option OPT_A %s' % ('AAAAAAA ' * 10).strip,
|
37
|
+
' %s' % ('AAAAAAA ' * 10).strip,
|
38
|
+
' --bbb-option OPT_B %s' % ('BBBBBBB ' * 10).strip,
|
39
|
+
' %s' % ('BBBBBBB ' * 10).strip
|
40
|
+
].join("\n")
|
41
|
+
end
|
24
42
|
end
|
25
43
|
|
26
44
|
describe 'adding an option with lower case description' do
|
@@ -86,8 +104,8 @@ describe HammerCLI::Help::Builder do
|
|
86
104
|
|
87
105
|
help.string.strip.must_equal [
|
88
106
|
'Options:',
|
89
|
-
' --option[-yyy|-bbb]
|
90
|
-
' --option[-aaa|-zzz]
|
107
|
+
' --option[-yyy|-bbb] VALUE Some description',
|
108
|
+
' --option[-aaa|-zzz] VALUE Some description'
|
91
109
|
].join("\n")
|
92
110
|
end
|
93
111
|
end
|
@@ -25,6 +25,10 @@ describe HammerCLI::Options::OptionDefinition do
|
|
25
25
|
option "--another-deprecated", "OLD_OPTION", "Test old option",
|
26
26
|
:context_target => :old_option,
|
27
27
|
:deprecated => "It is going to be removed"
|
28
|
+
|
29
|
+
def find_option(switch)
|
30
|
+
super(switch)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
def opt_with_deprecation(deprecation)
|
@@ -73,6 +77,14 @@ describe HammerCLI::Options::OptionDefinition do
|
|
73
77
|
context[:test_option].must_equal "VALUE"
|
74
78
|
end
|
75
79
|
|
80
|
+
it "doesn't print deprecation warning if the option is not used" do
|
81
|
+
context = {}
|
82
|
+
cmd = TestDeprecatedOptionCmd.new('', context)
|
83
|
+
cmd.find_option('--deprecated')
|
84
|
+
_out, err = capture_io { cmd.run([]) }
|
85
|
+
err.must_equal ''
|
86
|
+
end
|
87
|
+
|
76
88
|
it 'shows depracated message in help' do
|
77
89
|
opt = opt_with_deprecation("Use --better-switch instead")
|
78
90
|
opt.description.must_equal "Test option (Deprecated: Use --better-switch instead)"
|
@@ -98,4 +110,3 @@ describe HammerCLI::Options::OptionDefinition do
|
|
98
110
|
end
|
99
111
|
end
|
100
112
|
end
|
101
|
-
|
@@ -269,9 +269,9 @@ describe HammerCLI::Output::Definition do
|
|
269
269
|
sets_table = "---------|-----|---------|----\n" \
|
270
270
|
"FIELDS | ALL | DEFAULT | SET\n" \
|
271
271
|
"---------|-----|---------|----\n" \
|
272
|
-
"
|
273
|
-
"
|
274
|
-
"
|
272
|
+
"Newfield | x | x | \n" \
|
273
|
+
"Cf/abc | | | x \n" \
|
274
|
+
"Cf/bca | | | x \n" \
|
275
275
|
"---------|-----|---------|----\n"
|
276
276
|
|
277
277
|
definition.sets_table.must_equal sets_table
|
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:
|
4
|
+
version: 3.1.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: 2021-
|
12
|
+
date: 2021-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
@@ -152,30 +152,30 @@ executables:
|
|
152
152
|
- hammer-complete
|
153
153
|
extensions: []
|
154
154
|
extra_rdoc_files:
|
155
|
-
- doc/commands_modification.md
|
156
155
|
- doc/creating_apipie_commands.md
|
157
156
|
- doc/design.png
|
158
157
|
- doc/design.uml
|
159
|
-
- doc/developer_docs.md
|
160
158
|
- doc/development_tips.md
|
161
|
-
- doc/help_modification.md
|
162
159
|
- doc/i18n.md
|
163
160
|
- doc/installation_deb.md
|
164
161
|
- doc/installation_gem.md
|
165
162
|
- doc/option_builders.md
|
166
163
|
- doc/option_normalizers.md
|
167
|
-
- doc/output.md
|
168
|
-
- doc/review_checklist.md
|
169
164
|
- doc/writing_a_plugin.md
|
170
|
-
- doc/commands_extension.md
|
171
|
-
- doc/creating_commands.md
|
172
|
-
- doc/installation_rpm.md
|
173
165
|
- doc/installation_source.md
|
174
|
-
- doc/installation.md
|
175
166
|
- doc/release_notes.md
|
167
|
+
- doc/commands_extension.md
|
168
|
+
- doc/commands_modification.md
|
169
|
+
- doc/developer_docs.md
|
170
|
+
- doc/help_modification.md
|
171
|
+
- doc/installation.md
|
172
|
+
- doc/installation_rpm.md
|
173
|
+
- doc/output.md
|
174
|
+
- doc/review_checklist.md
|
175
|
+
- doc/creating_commands.md
|
176
176
|
- config/cli.modules.d/module_config_template.yml
|
177
|
-
- config/hammer.completion
|
178
177
|
- config/cli_config.template.yml
|
178
|
+
- config/hammer.completion
|
179
179
|
- README.md
|
180
180
|
files:
|
181
181
|
- LICENSE
|
@@ -394,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
394
394
|
- !ruby/object:Gem::Version
|
395
395
|
version: '0'
|
396
396
|
requirements: []
|
397
|
-
rubygems_version: 3.
|
397
|
+
rubygems_version: 3.1.2
|
398
398
|
signing_key:
|
399
399
|
specification_version: 4
|
400
400
|
summary: Universal command-line interface
|
@@ -404,18 +404,16 @@ test_files:
|
|
404
404
|
- test/functional/nil_values_test.rb
|
405
405
|
- test/functional/test_helper.rb
|
406
406
|
- test/test_helper.rb
|
407
|
-
- test/unit/apipie/api_connection_test.rb
|
408
407
|
- test/unit/apipie/command_test.rb
|
409
408
|
- test/unit/apipie/option_definition_test.rb
|
410
409
|
- test/unit/apipie/test_helper.rb
|
410
|
+
- test/unit/apipie/api_connection_test.rb
|
411
411
|
- test/unit/apipie/option_builder_test.rb
|
412
|
-
- test/unit/bash_test.rb
|
413
412
|
- test/unit/ca_cert_manager_test.rb
|
414
413
|
- test/unit/completer_test.rb
|
415
414
|
- test/unit/connection_test.rb
|
416
415
|
- test/unit/csv_parser_test.rb
|
417
416
|
- test/unit/defaults_test.rb
|
418
|
-
- test/unit/exception_handler_test.rb
|
419
417
|
- test/unit/fixtures/apipie/architectures.json
|
420
418
|
- test/unit/fixtures/apipie/documented.json
|
421
419
|
- test/unit/fixtures/certs/ca_cert.pem
|
@@ -425,9 +423,9 @@ test_files:
|
|
425
423
|
- test/unit/fixtures/json_input/invalid.json
|
426
424
|
- test/unit/fixtures/json_input/valid.json
|
427
425
|
- test/unit/help/definition/abstract_item_test.rb
|
426
|
+
- test/unit/help/definition/section_test.rb
|
428
427
|
- test/unit/help/definition/list_test.rb
|
429
428
|
- test/unit/help/definition/note_test.rb
|
430
|
-
- test/unit/help/definition/section_test.rb
|
431
429
|
- test/unit/help/definition/text_test.rb
|
432
430
|
- test/unit/help/definition_test.rb
|
433
431
|
- test/unit/help/text_builder_test.rb
|
@@ -440,14 +438,14 @@ test_files:
|
|
440
438
|
- test/unit/modules_test.rb
|
441
439
|
- test/unit/option_builder_test.rb
|
442
440
|
- test/unit/options/matcher_test.rb
|
443
|
-
- test/unit/options/normalizers_test.rb
|
444
441
|
- test/unit/options/option_collector_test.rb
|
445
|
-
- test/unit/options/option_definition_test.rb
|
446
442
|
- test/unit/options/processor_list_test.rb
|
447
443
|
- test/unit/options/sources/command_line_test.rb
|
448
444
|
- test/unit/options/sources/saved_defaults_test.rb
|
449
445
|
- test/unit/options/validators/dsl_test.rb
|
446
|
+
- test/unit/options/normalizers_test.rb
|
450
447
|
- test/unit/options/option_family_test.rb
|
448
|
+
- test/unit/options/option_definition_test.rb
|
451
449
|
- test/unit/output/adapter/abstract_test.rb
|
452
450
|
- test/unit/output/adapter/base_test.rb
|
453
451
|
- test/unit/output/adapter/csv_test.rb
|
@@ -455,14 +453,16 @@ test_files:
|
|
455
453
|
- test/unit/output/adapter/table_test.rb
|
456
454
|
- test/unit/output/adapter/yaml_test.rb
|
457
455
|
- test/unit/output/dsl_test.rb
|
458
|
-
- test/unit/output/field_filter_test.rb
|
459
456
|
- test/unit/output/fields_test.rb
|
460
|
-
- test/unit/output/formatters_test.rb
|
461
|
-
- test/unit/output/output_test.rb
|
462
457
|
- test/unit/output/record_collection_test.rb
|
463
458
|
- test/unit/output/definition_test.rb
|
459
|
+
- test/unit/output/field_filter_test.rb
|
460
|
+
- test/unit/output/formatters_test.rb
|
461
|
+
- test/unit/output/output_test.rb
|
464
462
|
- test/unit/settings_test.rb
|
465
463
|
- test/unit/test_helper.rb
|
466
464
|
- test/unit/utils_test.rb
|
465
|
+
- test/unit/bash_test.rb
|
466
|
+
- test/unit/exception_handler_test.rb
|
467
467
|
- test/unit/abstract_test.rb
|
468
468
|
- test/unit/command_extensions_test.rb
|