hammer_cli 2.1.1 → 2.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e7d0cc6fea99d3276fb653e462448bddc6b8977e0e5ed9df2a1f257365bee84
4
- data.tar.gz: 72123cef1ffaafb8979ff5e6bac55ca0fa9776e88800327ad41b48404a3a6284
3
+ metadata.gz: dae98160a2f04eb29858cd97cc219ebc440dbe8db359cd4c5c742ef164fb3c7d
4
+ data.tar.gz: 3c062268d65695c331953183322e23e373ac1359bc3110a1f48aed8d93f818f9
5
5
  SHA512:
6
- metadata.gz: 1514dfe8e1059a70da7af58887e9763d604eaec59ec438af136b2a430338ba0c4c9222e4e86f275fb12135165dabb1f51281daaba5ba48924e32d206307bd94e
7
- data.tar.gz: a17a67150e2bf0fb293f167d72cc5425e0fe0ebc9eb57c30144e5be952dbb45d8e370257408893727cfadcf3ce6d2607e098f90a1eb40955ff0dc98dc1ac39f1
6
+ metadata.gz: d12884641c2450d7b9893f5b8db2d13ad27958aabfbd06e9d763d8f35eb86ba813290c73933c6a4cdbf456c32f38d82ff96247f048ad6db4fe4bbd4feb0f0ad1
7
+ data.tar.gz: 05c7c44cbc98c2e3a4e4e3419120e7bacdc9131f8b0ec086762afe655179ccb7985764042d53e03839358447d5d87bcf20025a5635e0804ac45ec5fc694c0c27
@@ -1,8 +1,8 @@
1
1
  ### Installation from RPMs
2
2
 
3
- #### Step 1: setup yum repositories
3
+ #### Step 1: set up yum repositories
4
4
 
5
- For Foreman 1.3 stable the hammer packages are part of your installation repo and you can skip this step.
5
+ For Foreman 1.3 stable, the hammer packages are part of your installation repo and you can skip this step.
6
6
 
7
7
  You can choose from stable or nightly repo. Nightly has more recent version of hammer packages, but it was subject to less testing so there is a higher risk of issues.
8
8
  Add the Foreman yum repository to your yum repo files. For Fedora installations replace 'el6' with 'f18' or 'f19' as appropriate.
@@ -8,6 +8,7 @@ Clone and install CLI core
8
8
  ```bash
9
9
  $ git clone https://github.com/theforeman/hammer-cli.git
10
10
  $ cd hammer-cli
11
+ $ bundle install
11
12
  $ rake install
12
13
  $ cd ..
13
14
  ```
@@ -17,6 +18,7 @@ clone plugin with foreman commands
17
18
  ```bash
18
19
  $ git clone https://github.com/theforeman/hammer-cli-foreman.git
19
20
  $ cd hammer-cli-foreman
21
+ $ bundle install
20
22
  $ rake install
21
23
  $ cd ..
22
24
  ```
@@ -25,7 +27,8 @@ and optionally other plugins.
25
27
 
26
28
 
27
29
  #### Step 2: enable and configure the plugins
28
- You'll have to copy configuration files to proper locations manually.
29
- Please check our [configuration instructions](installation.md#configuration)
30
+ - Add the plugin as a gem to `Gemfile.local.rb`
31
+ - Copy the configuration files to proper locations manually,
32
+ please check our [configuration instructions](installation.md#configuration)
30
33
  and see how to proceed.
31
34
 
data/doc/release_notes.md CHANGED
@@ -1,9 +1,28 @@
1
1
  Release notes
2
2
  =============
3
- ### 2.1.1 (2020-05-29)
3
+ ### 2.3.1 (2021-05-04)
4
+ * Better family assignment for options, [#30996](http://projects.theforeman.org/issues/30996)
5
+
6
+ ### 2.3.0 (2020-11-03)
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
12
+
13
+ ### 2.3.0 (2020-11-03)
14
+ * Stop sending empty compute attrs param, [#30815](http://projects.theforeman.org/issues/30815)
15
+ * Make fuzzy search work in hammer shell ([PR #335](https://github.com/theforeman/hammer-cli/pull/335)), [#30747](http://projects.theforeman.org/issues/30747)
16
+ * Add details to installation from source doc ([PR #334](https://github.com/theforeman/hammer-cli/pull/334)), [#30666](http://projects.theforeman.org/issues/30666)
17
+ * Bump to 2.3.0-develop
18
+ * Bump to 2.2.0
19
+
20
+ ### 2.2.0 (2020-08-11)
21
+ * Update installation_rpm.md ([PR #333](https://github.com/theforeman/hammer-cli/pull/333))
4
22
  * Clean gem_release.ipynb up
5
23
  * Replace awesome_print with amazing_print ([PR #330](https://github.com/theforeman/hammer-cli/pull/330)), [#29846](http://projects.theforeman.org/issues/29846)
6
24
  * Fix typo: s/filed/feild/ ([PR #331](https://github.com/theforeman/hammer-cli/pull/331))
25
+ * Bump to 2.2.0-develop
7
26
 
8
27
  ### 2.1.0 (2020-05-14)
9
28
  * Hammer full-help returns correct output, [#29697](http://projects.theforeman.org/issues/29697)
@@ -190,18 +190,9 @@ 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? 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
193
+ next if option.nil? || option.switches.any? { |s| find_option(s) }
194
+
195
+ adjust_family(option) if option.respond_to?(:family)
205
196
  declared_options << option
206
197
  block ||= option.default_conversion_block
207
198
  define_accessors_for(option, &block)
@@ -411,6 +402,32 @@ module HammerCLI
411
402
 
412
403
  private
413
404
 
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
+
414
431
  def self.inherited_output_definition
415
432
  od = nil
416
433
  if superclass.respond_to? :output_definition
@@ -10,11 +10,11 @@ module HammerCLI::Apipie
10
10
  opts = {}
11
11
 
12
12
  params.each do |p|
13
- if p.expected_type == :hash
13
+ if p.expected_type == :hash && !p.params.empty?
14
14
  opts[p.name] = method_options_for_params(p.params, options)
15
15
  else
16
16
  p_name = HammerCLI.option_accessor_name(p.name)
17
- if options.has_key?(p_name)
17
+ if options.key?(p_name)
18
18
  opts[p.name] = options[p_name]
19
19
  elsif respond_to?(p_name, true)
20
20
  opt = send(p_name)
@@ -61,25 +61,6 @@ module HammerCLI
61
61
  label = HighLine.color(label, :bold) if @richtext
62
62
  puts label
63
63
  end
64
-
65
- private
66
-
67
- def expand_invocation_path(path)
68
- bits = path.split(' ')
69
- parent_command = HammerCLI::MainCommand
70
- new_path = (bits[1..-1] || []).each_with_object([]) do |bit, names|
71
- subcommand = parent_command.find_subcommand(bit)
72
- next if subcommand.nil?
73
-
74
- names << if subcommand.names.size > 1
75
- "<#{subcommand.names.join('|')}>"
76
- else
77
- subcommand.names.first
78
- end
79
- parent_command = subcommand.subcommand_class
80
- end
81
- new_path.unshift(bits.first).join(' ')
82
- end
83
64
  end
84
65
  end
85
66
  end
@@ -5,7 +5,7 @@ module HammerCLI
5
5
  class OptionFamily
6
6
  attr_reader :children
7
7
 
8
- IDS_REGEX = /\s?([Ii][Dd][s]?)\W|([Ii][Dd][s]?\Z)/
8
+ IDS_REGEX = /(\A[Ii][Dd][s]?)|\s([Ii][Dd][s]?)\W|([Ii][Dd][s]?\Z)/
9
9
 
10
10
  def initialize(options = {})
11
11
  @all = []
@@ -13,26 +13,32 @@ 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]
17
16
  @root = options[:root] || options[:aliased_resource] || options[:referenced_resource]
18
17
  end
19
18
 
20
19
  def description
21
20
  types = all.map(&:type).map { |s| s.split('_').last.to_s }
22
- .map(&:capitalize).join('/')
23
- @description ||= @parent.help[1].gsub(IDS_REGEX) { |w| w.gsub(/\w+/, types) }
21
+ .map(&:downcase).join('/')
22
+ parent_desc = @parent.help[1].gsub(IDS_REGEX) { |w| w.gsub(/\w+/, types) }
23
+ desc = parent_desc.strip.empty? ? @options[:description] : parent_desc
24
24
  if @options[:deprecation].class <= String
25
- format_deprecation_msg(@description, _('Deprecated: %{deprecated_msg}') % { deprecated_msg: @options[:deprecation] })
25
+ format_deprecation_msg(desc, _('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(@description, full_msg)
30
+ format_deprecation_msg(desc, full_msg)
31
31
  else
32
- @description
32
+ desc
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
+
36
42
  def switch
37
43
  return if @parent.nil? && @children.empty?
38
44
  return @parent.help_lhs.strip if @children.empty?
@@ -67,6 +73,9 @@ module HammerCLI
67
73
  end
68
74
 
69
75
  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
+
70
79
  child.family = self
71
80
  @children << child
72
81
  end
@@ -103,9 +112,7 @@ module HammerCLI
103
112
  max_len.downto(0) do |curr_len|
104
113
  0.upto(max_len - curr_len) do |start|
105
114
  root = shortest[start, curr_len]
106
- if switches.all? { |switch| switch.include?(root) }
107
- return root[2..-1].chomp('-')
108
- end
115
+ return root[2..-1].chomp('-') if switches.all? { |switch| switch.include?(root) }
109
116
  end
110
117
  end
111
118
  end
@@ -121,7 +121,7 @@ module HammerCLI
121
121
  bits = path.split(' ')
122
122
  parent_command = HammerCLI::MainCommand
123
123
  new_path = (bits[1..-1] || []).each_with_object([]) do |bit, names|
124
- subcommand = parent_command.find_subcommand(bit)
124
+ subcommand = parent_command.find_subcommand(bit, fuzzy: false)
125
125
  next if subcommand.nil?
126
126
 
127
127
  names << if subcommand.names.size > 1
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new "2.1.1"
3
+ @version ||= Gem::Version.new "2.3.1"
4
4
  end
5
5
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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.1.1
4
+ version: 2.3.1
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: 2020-05-29 00:00:00.000000000 Z
12
+ date: 2021-05-04 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_extension.md
156
155
  - doc/commands_modification.md
157
156
  - doc/creating_apipie_commands.md
158
- - doc/creating_commands.md
159
157
  - doc/design.png
160
158
  - doc/design.uml
161
159
  - doc/developer_docs.md
162
160
  - doc/development_tips.md
163
161
  - doc/help_modification.md
164
162
  - doc/i18n.md
165
- - doc/installation.md
166
163
  - doc/installation_deb.md
167
164
  - doc/installation_gem.md
168
- - doc/installation_rpm.md
169
- - doc/installation_source.md
170
165
  - doc/option_builders.md
171
166
  - doc/option_normalizers.md
172
167
  - doc/output.md
173
168
  - doc/review_checklist.md
174
169
  - doc/writing_a_plugin.md
170
+ - doc/commands_extension.md
171
+ - doc/creating_commands.md
172
+ - doc/installation_rpm.md
173
+ - doc/installation_source.md
174
+ - doc/installation.md
175
175
  - doc/release_notes.md
176
176
  - config/cli.modules.d/module_config_template.yml
177
- - config/cli_config.template.yml
178
177
  - config/hammer.completion
178
+ - config/cli_config.template.yml
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.1.2
397
+ rubygems_version: 3.0.8
398
398
  signing_key:
399
399
  specification_version: 4
400
400
  summary: Universal command-line interface
@@ -404,15 +404,13 @@ 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/abstract_test.rb
408
407
  - test/unit/apipie/api_connection_test.rb
409
408
  - test/unit/apipie/command_test.rb
410
- - test/unit/apipie/option_builder_test.rb
411
409
  - test/unit/apipie/option_definition_test.rb
412
410
  - test/unit/apipie/test_helper.rb
411
+ - test/unit/apipie/option_builder_test.rb
413
412
  - test/unit/bash_test.rb
414
413
  - test/unit/ca_cert_manager_test.rb
415
- - test/unit/command_extensions_test.rb
416
414
  - test/unit/completer_test.rb
417
415
  - test/unit/connection_test.rb
418
416
  - test/unit/csv_parser_test.rb
@@ -426,7 +424,6 @@ test_files:
426
424
  - test/unit/fixtures/defaults/defaults_dashed.yml
427
425
  - test/unit/fixtures/json_input/invalid.json
428
426
  - test/unit/fixtures/json_input/valid.json
429
- - test/unit/help/builder_test.rb
430
427
  - test/unit/help/definition/abstract_item_test.rb
431
428
  - test/unit/help/definition/list_test.rb
432
429
  - test/unit/help/definition/note_test.rb
@@ -434,6 +431,7 @@ test_files:
434
431
  - test/unit/help/definition/text_test.rb
435
432
  - test/unit/help/definition_test.rb
436
433
  - test/unit/help/text_builder_test.rb
434
+ - test/unit/help/builder_test.rb
437
435
  - test/unit/history_test.rb
438
436
  - test/unit/i18n_test.rb
439
437
  - test/unit/logger_test.rb
@@ -445,24 +443,26 @@ test_files:
445
443
  - test/unit/options/normalizers_test.rb
446
444
  - test/unit/options/option_collector_test.rb
447
445
  - test/unit/options/option_definition_test.rb
448
- - test/unit/options/option_family_test.rb
449
446
  - test/unit/options/processor_list_test.rb
450
447
  - test/unit/options/sources/command_line_test.rb
451
448
  - test/unit/options/sources/saved_defaults_test.rb
452
449
  - test/unit/options/validators/dsl_test.rb
450
+ - test/unit/options/option_family_test.rb
453
451
  - test/unit/output/adapter/abstract_test.rb
454
452
  - test/unit/output/adapter/base_test.rb
455
453
  - test/unit/output/adapter/csv_test.rb
456
454
  - test/unit/output/adapter/json_test.rb
457
455
  - test/unit/output/adapter/table_test.rb
458
456
  - test/unit/output/adapter/yaml_test.rb
459
- - test/unit/output/definition_test.rb
460
457
  - test/unit/output/dsl_test.rb
461
458
  - test/unit/output/field_filter_test.rb
462
459
  - test/unit/output/fields_test.rb
463
460
  - test/unit/output/formatters_test.rb
464
461
  - test/unit/output/output_test.rb
465
462
  - test/unit/output/record_collection_test.rb
463
+ - test/unit/output/definition_test.rb
466
464
  - test/unit/settings_test.rb
467
465
  - test/unit/test_helper.rb
468
466
  - test/unit/utils_test.rb
467
+ - test/unit/abstract_test.rb
468
+ - test/unit/command_extensions_test.rb