hammer_cli 2.3.1 → 2.4.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-complete +1 -3
- data/config/cli_config.template.yml +1 -1
- data/doc/installation.md +1 -1
- data/doc/release_notes.md +4 -9
- data/lib/hammer_cli/abstract.rb +12 -29
- data/lib/hammer_cli/bash/prebuild_command.rb +4 -2
- data/lib/hammer_cli/options/option_family.rb +10 -17
- data/lib/hammer_cli/settings.rb +1 -1
- data/lib/hammer_cli/version.rb +1 -1
- data/man/hammer.1.gz +0 -0
- metadata +75 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5d5eb556461a6873fe0b3b05bcc8a30aea17f88719b3c10c25106c73224884
|
4
|
+
data.tar.gz: 564721c9765ccd22b82fee81eea83be8b29da7ee0e415fd492deece64ca55b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efde2a000ba9e27da2a466496232399da3861bb69705631ca9113ecc88920cc0af9ff344536c858fe4fbb77e60fe886582919885983d03b4235da70b0e80a6dd
|
7
|
+
data.tar.gz: a2673ec7bb6c5ed621c7a068e67962fec2c038f99b12abe1f0f19fa85fad3711598aaa3abf52e7896e72db938f74c7726b350e8bebcd5eaf04c6ef02806c96f5
|
data/bin/hammer-complete
CHANGED
@@ -5,9 +5,7 @@ require 'English'
|
|
5
5
|
$LOAD_PATH.unshift(File.join(@project_root, 'lib'))
|
6
6
|
HAMMER = ENV['HAMMER'] || File.join(@project_root, 'bin/hammer')
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
completion_cache_file = ENV['HAMMER_COMPLETION_CACHE'] || '~/.cache/hammer_completion.yml'
|
8
|
+
completion_cache_file = ENV['HAMMER_COMPLETION_CACHE'] || '~/.cache/hammer_completion.json'
|
11
9
|
completion_cache_file = File.expand_path(completion_cache_file)
|
12
10
|
|
13
11
|
# build the cache if it does not exist
|
data/doc/installation.md
CHANGED
@@ -144,7 +144,7 @@ executable specified in `/etc/bash_completion.d/hammer`.
|
|
144
144
|
|
145
145
|
Bash completion for hammer needs pre-built cache that holds description of
|
146
146
|
all subcommands and its parameters. The cache is located by default in
|
147
|
-
`~/.cache/hammer_completion.
|
147
|
+
`~/.cache/hammer_completion.json`. The location can be changed in hammer's
|
148
148
|
config file. The cache can be built manually with
|
149
149
|
`hammer prebuild-bash-completion` or is built automatically when completion is
|
150
150
|
used and the cache is missing (this may cause slight delay). The cache expires
|
data/doc/release_notes.md
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
-
### 2.
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
* Stop sending empty compute attrs param, [#30815](http://projects.theforeman.org/issues/30815)
|
8
|
-
* Make fuzzy search work in hammer shell ([PR #335](https://github.com/theforeman/hammer-cli/pull/335)), [#30747](http://projects.theforeman.org/issues/30747)
|
9
|
-
* Add details to installation from source doc ([PR #334](https://github.com/theforeman/hammer-cli/pull/334)), [#30666](http://projects.theforeman.org/issues/30666)
|
10
|
-
* Bump to 2.3.0-develop
|
11
|
-
* Bump to 2.2.0
|
3
|
+
### 2.4.0 (2021-02-01)
|
4
|
+
* Expand path for bash completion file, [#30639](http://projects.theforeman.org/issues/30639)
|
5
|
+
* Remove release notes written twice
|
6
|
+
* Bump to 2.4.0-develop
|
12
7
|
|
13
8
|
### 2.3.0 (2020-11-03)
|
14
9
|
* Stop sending empty compute attrs param, [#30815](http://projects.theforeman.org/issues/30815)
|
data/lib/hammer_cli/abstract.rb
CHANGED
@@ -190,9 +190,18 @@ module HammerCLI
|
|
190
190
|
|
191
191
|
option_builder.build(builder_params).each do |option|
|
192
192
|
# skip switches that are already defined
|
193
|
-
next if option.nil?
|
194
|
-
|
195
|
-
|
193
|
+
next if option.nil? or option.switches.any? {|s| find_option(s) }
|
194
|
+
|
195
|
+
if option.respond_to?(:referenced_resource)
|
196
|
+
# Collect options that don't have family, but related to this parent.
|
197
|
+
children = find_options(
|
198
|
+
referenced_resource: option.referenced_resource.to_s,
|
199
|
+
aliased_resource: option.aliased_resource.to_s
|
200
|
+
).select { |o| o.family.nil? || o.family.head.nil? }
|
201
|
+
children.each do |child|
|
202
|
+
option.family.adopt(child) if option.family
|
203
|
+
end
|
204
|
+
end
|
196
205
|
declared_options << option
|
197
206
|
block ||= option.default_conversion_block
|
198
207
|
define_accessors_for(option, &block)
|
@@ -402,32 +411,6 @@ module HammerCLI
|
|
402
411
|
|
403
412
|
private
|
404
413
|
|
405
|
-
def self.adjust_family(option)
|
406
|
-
# Collect options that should share the same family
|
407
|
-
# If those options have family, adopt the current one
|
408
|
-
# Else adopt those options to the family of the current option
|
409
|
-
# NOTE: this shouldn't rewrite any options,
|
410
|
-
# although options from similar family could be adopted (appended)
|
411
|
-
options = find_options(
|
412
|
-
aliased_resource: option.aliased_resource.to_s
|
413
|
-
).select { |o| o.family.nil? || o.family.formats.include?(option.value_formatter.class) }.group_by do |o|
|
414
|
-
next :to_skip if option.family.children.include?(o)
|
415
|
-
next :to_adopt if o.family.nil? || o.family.head.nil?
|
416
|
-
next :to_skip if o.family.children.include?(option)
|
417
|
-
# If both family heads handle the same switch
|
418
|
-
# then `option` is probably from similar family and can be adopted
|
419
|
-
next :adopt_by if option.family.head.nil? || o.family.head.handles?(option.family.head.long_switch)
|
420
|
-
|
421
|
-
:to_skip
|
422
|
-
end
|
423
|
-
options[:to_adopt]&.each do |child|
|
424
|
-
option.family&.adopt(child)
|
425
|
-
end
|
426
|
-
options[:adopt_by]&.map(&:family)&.uniq&.each do |family|
|
427
|
-
family.adopt(option)
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
414
|
def self.inherited_output_definition
|
432
415
|
od = nil
|
433
416
|
if superclass.respond_to? :output_definition
|
@@ -3,10 +3,12 @@ module HammerCLI
|
|
3
3
|
class PrebuildCompletionCommand < HammerCLI::AbstractCommand
|
4
4
|
def execute
|
5
5
|
map = HammerCLI::MainCommand.completion_map
|
6
|
-
cache_file =
|
6
|
+
cache_file = File.expand_path(
|
7
|
+
HammerCLI::Settings.get(:completion_cache_file)
|
8
|
+
)
|
7
9
|
cache_dir = File.dirname(cache_file)
|
8
10
|
FileUtils.mkdir_p(cache_dir) unless File.directory?(cache_dir)
|
9
|
-
File.write(
|
11
|
+
File.write(cache_file, map.to_json)
|
10
12
|
|
11
13
|
HammerCLI::EX_OK
|
12
14
|
end
|
@@ -5,7 +5,7 @@ module HammerCLI
|
|
5
5
|
class OptionFamily
|
6
6
|
attr_reader :children
|
7
7
|
|
8
|
-
IDS_REGEX =
|
8
|
+
IDS_REGEX = /\s?([Ii][Dd][s]?)\W|([Ii][Dd][s]?\Z)/
|
9
9
|
|
10
10
|
def initialize(options = {})
|
11
11
|
@all = []
|
@@ -13,32 +13,26 @@ module HammerCLI
|
|
13
13
|
@options = options
|
14
14
|
@creator = options[:creator] || Class.new(HammerCLI::Apipie::Command)
|
15
15
|
@prefix = options[:prefix]
|
16
|
+
@description = options[:description]
|
16
17
|
@root = options[:root] || options[:aliased_resource] || options[:referenced_resource]
|
17
18
|
end
|
18
19
|
|
19
20
|
def description
|
20
21
|
types = all.map(&:type).map { |s| s.split('_').last.to_s }
|
21
|
-
.map(&:
|
22
|
-
|
23
|
-
desc = parent_desc.strip.empty? ? @options[:description] : parent_desc
|
22
|
+
.map(&:capitalize).join('/')
|
23
|
+
@description ||= @parent.help[1].gsub(IDS_REGEX) { |w| w.gsub(/\w+/, types) }
|
24
24
|
if @options[:deprecation].class <= String
|
25
|
-
format_deprecation_msg(
|
25
|
+
format_deprecation_msg(@description, _('Deprecated: %{deprecated_msg}') % { deprecated_msg: @options[:deprecation] })
|
26
26
|
elsif @options[:deprecation].class <= Hash
|
27
27
|
full_msg = @options[:deprecation].map do |flag, msg|
|
28
28
|
_('%{flag} is deprecated: %{deprecated_msg}') % { flag: flag, deprecated_msg: msg }
|
29
29
|
end.join(', ')
|
30
|
-
format_deprecation_msg(
|
30
|
+
format_deprecation_msg(@description, full_msg)
|
31
31
|
else
|
32
|
-
|
32
|
+
@description
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def formats
|
37
|
-
return [@options[:format].class] if @options[:format]
|
38
|
-
|
39
|
-
all.map(&:value_formatter).map(&:class).uniq
|
40
|
-
end
|
41
|
-
|
42
36
|
def switch
|
43
37
|
return if @parent.nil? && @children.empty?
|
44
38
|
return @parent.help_lhs.strip if @children.empty?
|
@@ -73,9 +67,6 @@ module HammerCLI
|
|
73
67
|
end
|
74
68
|
|
75
69
|
def adopt(child)
|
76
|
-
raise ArgumentError, 'Parent cannot be a child within the same family' if child == @parent
|
77
|
-
raise ArgumentError, 'Child is already in the family' if @children.include?(child)
|
78
|
-
|
79
70
|
child.family = self
|
80
71
|
@children << child
|
81
72
|
end
|
@@ -112,7 +103,9 @@ module HammerCLI
|
|
112
103
|
max_len.downto(0) do |curr_len|
|
113
104
|
0.upto(max_len - curr_len) do |start|
|
114
105
|
root = shortest[start, curr_len]
|
115
|
-
|
106
|
+
if switches.all? { |switch| switch.include?(root) }
|
107
|
+
return root[2..-1].chomp('-')
|
108
|
+
end
|
116
109
|
end
|
117
110
|
end
|
118
111
|
end
|
data/lib/hammer_cli/settings.rb
CHANGED
data/lib/hammer_cli/version.rb
CHANGED
data/man/hammer.1.gz
CHANGED
Binary file
|
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: 2.
|
4
|
+
version: 2.4.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-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
@@ -145,37 +145,37 @@ dependencies:
|
|
145
145
|
version: 0.2.0
|
146
146
|
description: 'Hammer cli provides universal extendable CLI interface for ruby apps
|
147
147
|
|
148
|
-
'
|
148
|
+
'
|
149
149
|
email: mbacovsk@redhat.com
|
150
150
|
executables:
|
151
151
|
- hammer
|
152
152
|
- hammer-complete
|
153
153
|
extensions: []
|
154
154
|
extra_rdoc_files:
|
155
|
-
- doc/
|
156
|
-
- doc/
|
155
|
+
- doc/commands_extension.md
|
156
|
+
- doc/release_notes.md
|
157
157
|
- doc/design.png
|
158
|
-
- doc/
|
159
|
-
- doc/
|
158
|
+
- doc/commands_modification.md
|
159
|
+
- doc/installation.md
|
160
160
|
- doc/development_tips.md
|
161
|
-
- doc/
|
162
|
-
- doc/
|
161
|
+
- doc/writing_a_plugin.md
|
162
|
+
- doc/output.md
|
163
|
+
- doc/developer_docs.md
|
163
164
|
- doc/installation_deb.md
|
164
|
-
- doc/installation_gem.md
|
165
|
-
- doc/option_builders.md
|
166
165
|
- doc/option_normalizers.md
|
167
|
-
- doc/output.md
|
168
|
-
- doc/review_checklist.md
|
169
|
-
- doc/writing_a_plugin.md
|
170
|
-
- doc/commands_extension.md
|
171
|
-
- doc/creating_commands.md
|
172
166
|
- doc/installation_rpm.md
|
167
|
+
- doc/installation_gem.md
|
168
|
+
- doc/help_modification.md
|
169
|
+
- doc/creating_commands.md
|
173
170
|
- doc/installation_source.md
|
174
|
-
- doc/
|
175
|
-
- doc/
|
171
|
+
- doc/option_builders.md
|
172
|
+
- doc/i18n.md
|
173
|
+
- doc/review_checklist.md
|
174
|
+
- doc/creating_apipie_commands.md
|
175
|
+
- doc/design.uml
|
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
|
@@ -399,70 +399,70 @@ signing_key:
|
|
399
399
|
specification_version: 4
|
400
400
|
summary: Universal command-line interface
|
401
401
|
test_files:
|
402
|
-
- test/
|
403
|
-
- test/
|
404
|
-
- test/
|
405
|
-
- test/functional/test_helper.rb
|
406
|
-
- test/test_helper.rb
|
407
|
-
- test/unit/apipie/api_connection_test.rb
|
408
|
-
- test/unit/apipie/command_test.rb
|
409
|
-
- test/unit/apipie/option_definition_test.rb
|
410
|
-
- test/unit/apipie/test_helper.rb
|
411
|
-
- test/unit/apipie/option_builder_test.rb
|
412
|
-
- test/unit/bash_test.rb
|
413
|
-
- test/unit/ca_cert_manager_test.rb
|
414
|
-
- test/unit/completer_test.rb
|
402
|
+
- test/unit/messages_test.rb
|
403
|
+
- test/unit/exception_handler_test.rb
|
404
|
+
- test/unit/modules_test.rb
|
415
405
|
- test/unit/connection_test.rb
|
406
|
+
- test/unit/completer_test.rb
|
416
407
|
- test/unit/csv_parser_test.rb
|
408
|
+
- test/unit/option_builder_test.rb
|
409
|
+
- test/unit/test_helper.rb
|
410
|
+
- test/unit/utils_test.rb
|
411
|
+
- test/unit/apipie/command_test.rb
|
412
|
+
- test/unit/apipie/option_builder_test.rb
|
413
|
+
- test/unit/apipie/test_helper.rb
|
414
|
+
- test/unit/apipie/api_connection_test.rb
|
415
|
+
- test/unit/apipie/option_definition_test.rb
|
416
|
+
- test/unit/command_extensions_test.rb
|
417
|
+
- test/unit/main_test.rb
|
418
|
+
- test/unit/options/processor_list_test.rb
|
419
|
+
- test/unit/options/option_family_test.rb
|
420
|
+
- test/unit/options/validators/dsl_test.rb
|
421
|
+
- test/unit/options/sources/command_line_test.rb
|
422
|
+
- test/unit/options/sources/saved_defaults_test.rb
|
423
|
+
- test/unit/options/matcher_test.rb
|
424
|
+
- test/unit/options/option_collector_test.rb
|
425
|
+
- test/unit/options/normalizers_test.rb
|
426
|
+
- test/unit/options/option_definition_test.rb
|
427
|
+
- test/unit/settings_test.rb
|
428
|
+
- test/unit/history_test.rb
|
417
429
|
- test/unit/defaults_test.rb
|
418
|
-
- test/unit/
|
430
|
+
- test/unit/logger_test.rb
|
431
|
+
- test/unit/output/formatters_test.rb
|
432
|
+
- test/unit/output/record_collection_test.rb
|
433
|
+
- test/unit/output/dsl_test.rb
|
434
|
+
- test/unit/output/definition_test.rb
|
435
|
+
- test/unit/output/output_test.rb
|
436
|
+
- test/unit/output/field_filter_test.rb
|
437
|
+
- test/unit/output/fields_test.rb
|
438
|
+
- test/unit/output/adapter/table_test.rb
|
439
|
+
- test/unit/output/adapter/json_test.rb
|
440
|
+
- test/unit/output/adapter/abstract_test.rb
|
441
|
+
- test/unit/output/adapter/yaml_test.rb
|
442
|
+
- test/unit/output/adapter/csv_test.rb
|
443
|
+
- test/unit/output/adapter/base_test.rb
|
444
|
+
- test/unit/abstract_test.rb
|
445
|
+
- test/unit/i18n_test.rb
|
419
446
|
- test/unit/fixtures/apipie/architectures.json
|
420
447
|
- test/unit/fixtures/apipie/documented.json
|
421
|
-
- test/unit/fixtures/certs/ca_cert.pem
|
422
|
-
- test/unit/fixtures/certs/non_ca_cert.pem
|
423
|
-
- test/unit/fixtures/defaults/defaults.yml
|
424
448
|
- test/unit/fixtures/defaults/defaults_dashed.yml
|
425
|
-
- test/unit/fixtures/
|
449
|
+
- test/unit/fixtures/defaults/defaults.yml
|
426
450
|
- test/unit/fixtures/json_input/valid.json
|
427
|
-
- test/unit/
|
428
|
-
- test/unit/
|
429
|
-
- test/unit/
|
451
|
+
- test/unit/fixtures/json_input/invalid.json
|
452
|
+
- test/unit/fixtures/certs/ca_cert.pem
|
453
|
+
- test/unit/fixtures/certs/non_ca_cert.pem
|
454
|
+
- test/unit/bash_test.rb
|
430
455
|
- test/unit/help/definition/section_test.rb
|
456
|
+
- test/unit/help/definition/list_test.rb
|
431
457
|
- test/unit/help/definition/text_test.rb
|
458
|
+
- test/unit/help/definition/abstract_item_test.rb
|
459
|
+
- test/unit/help/definition/note_test.rb
|
432
460
|
- test/unit/help/definition_test.rb
|
433
|
-
- test/unit/help/text_builder_test.rb
|
434
461
|
- test/unit/help/builder_test.rb
|
435
|
-
- test/unit/
|
436
|
-
- test/unit/
|
437
|
-
- test/
|
438
|
-
- test/
|
439
|
-
- test/
|
440
|
-
- test/
|
441
|
-
- test/
|
442
|
-
- test/unit/options/matcher_test.rb
|
443
|
-
- test/unit/options/normalizers_test.rb
|
444
|
-
- test/unit/options/option_collector_test.rb
|
445
|
-
- test/unit/options/option_definition_test.rb
|
446
|
-
- test/unit/options/processor_list_test.rb
|
447
|
-
- test/unit/options/sources/command_line_test.rb
|
448
|
-
- test/unit/options/sources/saved_defaults_test.rb
|
449
|
-
- test/unit/options/validators/dsl_test.rb
|
450
|
-
- test/unit/options/option_family_test.rb
|
451
|
-
- test/unit/output/adapter/abstract_test.rb
|
452
|
-
- test/unit/output/adapter/base_test.rb
|
453
|
-
- test/unit/output/adapter/csv_test.rb
|
454
|
-
- test/unit/output/adapter/json_test.rb
|
455
|
-
- test/unit/output/adapter/table_test.rb
|
456
|
-
- test/unit/output/adapter/yaml_test.rb
|
457
|
-
- test/unit/output/dsl_test.rb
|
458
|
-
- test/unit/output/field_filter_test.rb
|
459
|
-
- test/unit/output/fields_test.rb
|
460
|
-
- test/unit/output/formatters_test.rb
|
461
|
-
- test/unit/output/output_test.rb
|
462
|
-
- test/unit/output/record_collection_test.rb
|
463
|
-
- test/unit/output/definition_test.rb
|
464
|
-
- test/unit/settings_test.rb
|
465
|
-
- test/unit/test_helper.rb
|
466
|
-
- test/unit/utils_test.rb
|
467
|
-
- test/unit/abstract_test.rb
|
468
|
-
- test/unit/command_extensions_test.rb
|
462
|
+
- test/unit/help/text_builder_test.rb
|
463
|
+
- test/unit/ca_cert_manager_test.rb
|
464
|
+
- test/functional/help_test.rb
|
465
|
+
- test/functional/test_helper.rb
|
466
|
+
- test/functional/nil_values_test.rb
|
467
|
+
- test/functional/defaults_test.rb
|
468
|
+
- test/test_helper.rb
|