hammer_cli 3.5.1 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/config/cli_config.template.yml +3 -3
  3. data/doc/release_notes.md +13 -1
  4. data/lib/hammer_cli/abstract.rb +1 -1
  5. data/lib/hammer_cli/defaults_commands.rb +0 -1
  6. data/lib/hammer_cli/help/builder.rb +6 -6
  7. data/lib/hammer_cli/logger.rb +2 -2
  8. data/lib/hammer_cli/modules.rb +1 -1
  9. data/lib/hammer_cli/options/normalizers.rb +2 -2
  10. data/lib/hammer_cli/options/validators/dsl.rb +1 -1
  11. data/lib/hammer_cli/output/adapter/csv.rb +0 -1
  12. data/lib/hammer_cli/output/dsl.rb +1 -1
  13. data/lib/hammer_cli/output/fields.rb +1 -1
  14. data/lib/hammer_cli/output/formatters.rb +4 -4
  15. data/lib/hammer_cli/ssloptions.rb +3 -3
  16. data/lib/hammer_cli/subcommand.rb +1 -0
  17. data/lib/hammer_cli/utils.rb +0 -12
  18. data/lib/hammer_cli/version.rb +1 -1
  19. data/locale/Makefile.def +77 -0
  20. data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
  21. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  22. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  23. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  24. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  25. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  26. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  27. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  28. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  29. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  30. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  31. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  32. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  33. data/test/functional/defaults_test.rb +0 -1
  34. data/test/test_helper.rb +1 -1
  35. data/test/unit/apipie/command_test.rb +1 -1
  36. data/test/unit/apipie/option_definition_test.rb +1 -1
  37. data/test/unit/exception_handler_test.rb +3 -3
  38. data/test/unit/history_test.rb +2 -2
  39. data/test/unit/logger_test.rb +2 -2
  40. data/test/unit/options/option_definition_test.rb +4 -4
  41. data/test/unit/options/sources/saved_defaults_test.rb +0 -4
  42. data/test/unit/output/adapter/abstract_test.rb +3 -3
  43. data/test/unit/output/adapter/csv_test.rb +21 -21
  44. data/test/unit/output/adapter/table_test.rb +5 -5
  45. metadata +35 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fef4527d2b222db1e8a5c4cd4c1f1935d9434a4faca25b1d1e862958610f6a4e
4
- data.tar.gz: 1dea2d3ade1019d4a00dfdecfc1ece96782c60e24d4561d96b8abd9eeeb03219
3
+ metadata.gz: 5c8ba63d251f23a5e6005d7adcab02b5045639060c1bd5a3a02741e6d5561945
4
+ data.tar.gz: b94fd6c3342e7c8b06efeb7dfe754f449cd0ce76b62cc7cafadf13031fbf2f94
5
5
  SHA512:
6
- metadata.gz: bd18a75dc52b4185cf4d88d75c1cfb1c09881c7ce9fd5542038d64c11c8300c70cbdcc54e56993c9208834d645c64acd30ae72c374c5c0c58146f1b822c930d6
7
- data.tar.gz: e1e115dc06bc8a02d3ea01c6dc2f63631111db1fcae58906c1216186cd9253f16da5522364d2b36be3dce970f4c5ae3172a1a57492e93a975da9e2afebdb2a19
6
+ metadata.gz: 26dc0d7d6b439aa97d1e5a01f003cc8c817ad522baa874b6cb8fc145e03246fce952ef96e0def406c614b3b4246fb85b69d3a6c7e10090cf7f7c152c53657715
7
+ data.tar.gz: 8f64e1a44462aa152f2f5aeb5af69f05160978651eaa9a2ba327ea1ceb6f77fffdcef3a436d113a5877edb05a2d0781bb3bce1329b8bb559856ba3ef6e159a75
@@ -7,7 +7,7 @@
7
7
  # Location of shell history file
8
8
  :history_file: '~/.hammer/history'
9
9
  # Mark translated strings with X characters (for developers)
10
- #:mark_translated: false
10
+ # :mark_translated: false
11
11
  # Hide headers from output of list actions
12
12
  # :no_headers: true
13
13
  # Choose capitalization for JSON/YAML output.
@@ -17,7 +17,7 @@
17
17
  # Enable/disable color output of logger in Clamp commands
18
18
  :watch_plain: false
19
19
 
20
- # Forece relaod of Apipie cache with every Hammer invocation
20
+ # Force reload of Apipie cache with every Hammer invocation
21
21
  :reload_cache: false
22
22
 
23
23
  # Directory where the logs are stored. The default is /var/log/hammer/ and the log file is named hammer.log
@@ -75,5 +75,5 @@
75
75
  # Certs from the local storage are used only when neither :ssl_ca_file: nor :ssl_ca_path: is cofigured.
76
76
  #:local_ca_store_path: '~/.hammer/certs'
77
77
 
78
- # Allows setting the SSL version to use when making API calls
78
+ # Allows setting the SSL version to use when making API calls
79
79
  #:ssl_version: 'TLSv1_2'
data/doc/release_notes.md CHANGED
@@ -1,7 +1,19 @@
1
1
  Release notes
2
2
  =============
3
- ### 3.5.1 (2023-02-28)
3
+ ### 3.7.0 (2023-05-23)
4
+ * Honor tz in datetime normalizer ([PR #369](https://github.com/theforeman/hammer-cli/pull/369)), [#36418](http://projects.theforeman.org/issues/36418)
5
+ * Remove unused code, [#36337](http://projects.theforeman.org/issues/36337)
6
+ * Fix ambiguous operator warnings, [#36337](http://projects.theforeman.org/issues/36337)
7
+ * Update rake and clamp deps, [#36337](http://projects.theforeman.org/issues/36337)
8
+ * Fix config template typos ([PR #365](https://github.com/theforeman/hammer-cli/pull/365))
9
+ * Load ssl key using openssl::pkey.read ([PR #364](https://github.com/theforeman/hammer-cli/pull/364)), [#34853](http://projects.theforeman.org/issues/34853)
10
+ * Bump to 3.7.0-develop
11
+
12
+ ### 3.6.0 (2023-02-23)
4
13
  * Update apipie-bindings to 0.6.0
14
+ * Include makefile.def in the gem
15
+ * Correct mocha inclusion in tests
16
+ * Bump to 3.6.0-develop
5
17
 
6
18
  ### 3.5.0 (2022-10-31)
7
19
  * Bump to 3.5.0-develop
@@ -192,7 +192,7 @@ module HammerCLI
192
192
 
193
193
  def self.output(definition=nil, &block)
194
194
  dsl = HammerCLI::Output::Dsl.new
195
- dsl.build &block if block_given?
195
+ dsl.build(&block) if block_given?
196
196
  output_definition.append definition.fields unless definition.nil?
197
197
  output_definition.append dsl.fields
198
198
  end
@@ -1,4 +1,3 @@
1
- require 'hammer_cli'
2
1
  require 'yaml'
3
2
  module HammerCLI
4
3
  class BaseDefaultsProvider
@@ -14,7 +14,7 @@ module HammerCLI
14
14
  def add_usage(invocation_path, usage_descriptions)
15
15
  heading(Clamp.message(:usage_heading))
16
16
  usage_descriptions.each do |usage|
17
- puts " #{HammerCLI.expand_invocation_path(invocation_path)} #{usage}".rstrip
17
+ line " #{HammerCLI.expand_invocation_path(invocation_path)} #{usage}".rstrip
18
18
  end
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ module HammerCLI
24
24
  end
25
25
  items.reject! {|item| item.respond_to?(:hidden?) && item.hidden?}
26
26
 
27
- puts
27
+ line
28
28
  heading(heading)
29
29
 
30
30
  label_width = DEFAULT_LABEL_INDENT
@@ -47,15 +47,15 @@ module HammerCLI
47
47
  item.help
48
48
  end
49
49
  description.gsub(/^(.)/) { Unicode.capitalize(Regexp.last_match(1)) }.wrap.each_line do |line|
50
- puts " %-#{label_width}s %s" % [label, line]
50
+ line " %-#{label_width}s %s" % [label, line]
51
51
  label = ''
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
56
  def add_text(content)
57
- puts
58
- puts content
57
+ line
58
+ line content
59
59
  end
60
60
 
61
61
  protected
@@ -63,7 +63,7 @@ module HammerCLI
63
63
  def heading(label)
64
64
  label = "#{label}:"
65
65
  label = HighLine.color(label, :bold) if @richtext
66
- puts label
66
+ line label
67
67
  end
68
68
  end
69
69
  end
@@ -54,7 +54,7 @@ module HammerCLI
54
54
  log_dir = File.expand_path(HammerCLI::Settings.get(:log_dir) || DEFAULT_LOG_DIR)
55
55
  begin
56
56
  FileUtils.mkdir_p(log_dir, :mode => 0750)
57
- rescue Errno::EACCES => e
57
+ rescue Errno::EACCES
58
58
  $stderr.puts _("No permissions to create log dir %s.") % log_dir
59
59
  end
60
60
 
@@ -68,7 +68,7 @@ module HammerCLI
68
68
  :size => (HammerCLI::Settings.get(:log_size) || 1)*1024*1024) # 1MB
69
69
  # set owner and group (it's ignored if attribute is nil)
70
70
  FileUtils.chown HammerCLI::Settings.get(:log_owner), HammerCLI::Settings.get(:log_group), filename
71
- rescue ArgumentError => e
71
+ rescue ArgumentError
72
72
  $stderr.puts _("File %s not writeable, won't log anything to the file!") % filename
73
73
  end
74
74
 
@@ -67,7 +67,7 @@ module HammerCLI
67
67
 
68
68
  def self.load(name)
69
69
  load! name
70
- rescue Exception => e
70
+ rescue Exception
71
71
  false
72
72
  end
73
73
 
@@ -298,7 +298,7 @@ module HammerCLI
298
298
  json_string = ::File.exist?(::File.expand_path(val)) ? super(val) : val
299
299
  ::JSON.parse(json_string)
300
300
 
301
- rescue ::JSON::ParserError => e
301
+ rescue ::JSON::ParserError
302
302
  raise ArgumentError, _("Unable to parse JSON input.")
303
303
  end
304
304
 
@@ -368,7 +368,7 @@ module HammerCLI
368
368
 
369
369
  def format(date)
370
370
  raise ArgumentError unless date
371
- ::DateTime.parse(date).to_s
371
+ ::Time.parse(date).iso8601
372
372
  rescue ArgumentError
373
373
  raise ArgumentError, _("'%s' is not a valid date.") % date
374
374
  end
@@ -152,7 +152,7 @@ module HammerCLI
152
152
  end
153
153
 
154
154
  def run(&block)
155
- self.instance_eval &block
155
+ self.instance_eval(&block)
156
156
  end
157
157
  end
158
158
  end
@@ -94,7 +94,6 @@ module HammerCLI::Output::Adapter
94
94
  @name = nil
95
95
  @prefixes = []
96
96
  @suffixes = []
97
- @data
98
97
  end
99
98
 
100
99
  def append_suffix(suffix)
@@ -12,7 +12,7 @@ module HammerCLI::Output
12
12
  end
13
13
 
14
14
  def build(&block)
15
- self.instance_eval &block
15
+ self.instance_eval(&block)
16
16
  end
17
17
 
18
18
  protected
@@ -72,7 +72,7 @@ module Fields
72
72
  def initialize(options={}, &block)
73
73
  super(options)
74
74
  dsl = HammerCLI::Output::Dsl.new
75
- dsl.build &block if block_given?
75
+ dsl.build(&block) if block_given?
76
76
  dsl.fields.each { |f| f.parent = self }
77
77
  self.output_definition.append dsl.fields
78
78
  end
@@ -13,7 +13,7 @@ module HammerCLI::Output
13
13
 
14
14
  def register_formatter(type, *formatters)
15
15
  if @_formatters[type].nil?
16
- @_formatters[type] = FormatterContainer.new *formatters
16
+ @_formatters[type] = FormatterContainer.new(*formatters)
17
17
  else
18
18
  formatters.each { |f| @_formatters[type].add_formatter(f) }
19
19
  end
@@ -84,8 +84,8 @@ module HammerCLI::Output
84
84
  tags.map { |t| HammerCLI::Output::Utils.tag_to_feature(t) }
85
85
  end
86
86
 
87
- def format(data, field_params={})
88
- c = HighLine.color(data.to_s, @color)
87
+ def format(data, _={})
88
+ HighLine.color(data.to_s, @color)
89
89
  end
90
90
  end
91
91
 
@@ -97,7 +97,7 @@ module HammerCLI::Output
97
97
  tags.map { |t| HammerCLI::Output::Utils.tag_to_feature(t) }
98
98
  end
99
99
 
100
- def format(string_date, field_params={})
100
+ def format(string_date, _={})
101
101
  t = DateTime.parse(string_date.to_s)
102
102
  t.strftime("%Y/%m/%d %H:%M:%S")
103
103
  rescue ArgumentError
@@ -68,13 +68,13 @@ module HammerCLI
68
68
 
69
69
  def read_certificate(path)
70
70
  OpenSSL::X509::Certificate.new(File.read(path)) unless path.nil?
71
- rescue SystemCallError => e
71
+ rescue SystemCallError
72
72
  warn _("Could't read SSL client certificate %s.") % path
73
73
  end
74
74
 
75
75
  def read_key(path)
76
- OpenSSL::PKey::RSA.new(File.read(path)) unless path.nil?
77
- rescue SystemCallError => e
76
+ OpenSSL::PKey.read(File.read(path)) unless path.nil?
77
+ rescue SystemCallError
78
78
  warn _("Could't read SSL client key %s.") % path
79
79
  end
80
80
  end
@@ -11,6 +11,7 @@ module HammerCLI
11
11
  @subcommand_class = subcommand_class
12
12
  @hidden = options[:hidden]
13
13
  @warning = options[:warning]
14
+ super(@names, @description, @subcommand_class)
14
15
  end
15
16
 
16
17
  def hidden?
@@ -48,18 +48,6 @@ class String
48
48
  end
49
49
  end
50
50
 
51
- class Hash
52
- # for ruby < 2.5.0
53
- def transform_keys
54
- result = {}
55
- each do |key, value|
56
- new_key = yield key
57
- result[new_key] = value
58
- end
59
- result
60
- end
61
- end
62
-
63
51
  module HammerCLI
64
52
 
65
53
  def self.tty?
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new "3.5.1"
3
+ @version ||= Gem::Version.new "3.7.0"
4
4
  end
5
5
  end
@@ -0,0 +1,77 @@
1
+ #
2
+ # Definition of common Makefile tasks for PO merging and MO generation.
3
+ #
4
+ # Run make help to list available targets
5
+ #
6
+
7
+ POTFILE = $(DOMAIN).pot
8
+ MOFILE = $(DOMAIN).mo
9
+ POFILES = $(shell find . -name '$(DOMAIN).po')
10
+ MOFILES = $(patsubst %.po,%.mo,$(POFILES))
11
+ POXFILES = $(patsubst %.po,%.pox,$(POFILES))
12
+ EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
13
+ TIMESTAMPFILES = $(patsubst %.po,%.po.time_stamp,$(POFILES))
14
+
15
+ %.mo: %.po
16
+ mkdir -p $(shell dirname $@)/LC_MESSAGES
17
+ msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
18
+
19
+ .PHONY: all-mo
20
+ all-mo: $(MOFILES) ## Generate MO files from PO files (default)
21
+
22
+ # Check for malformed strings
23
+ %.pox: %.po
24
+ @command -v pofilter >/dev/null 2>&1 || { echo "Command pofilter not found. Make sure you have translate-toolkit installed." >&2; exit 1; }
25
+ msgfmt -c $<
26
+ pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
27
+ -t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@;
28
+ cat $@
29
+ ! grep -q msgid $@
30
+
31
+ .PHONY: check
32
+ check: $(POXFILES) ## Check translations using translate-tool, run make with -k to skip errors and execute for all languages
33
+
34
+ .PHONY: uniq-po
35
+ uniq-po: ## Unify duplicate translations in .po files
36
+ for f in $(shell find ./ -name "*.po") ; do \
37
+ msguniq $$f -o $$f ; \
38
+ done
39
+
40
+ %.edit.po:
41
+ touch $@
42
+
43
+ # Pull translaions from transifex
44
+ .PHONY: tx-pull
45
+ tx-pull: $(EDITFILES)
46
+ @command -v tx >/dev/null 2>&1 || { echo "Command tx not found. Make sure you have transifex-client installed and configured." >&2; exit 1; }
47
+ tx pull -f
48
+ for f in $(EDITFILES); do \
49
+ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
50
+ done
51
+
52
+ # Merge .edit.po into .po
53
+ .PHONY: update-po
54
+ update-po:
55
+ for f in $(EDITFILES); do \
56
+ msgcat --use-first --no-location $$f $${f//.edit/} > $${f//.edit/}; \
57
+ done
58
+
59
+ # Extract strings and update the .pot, prepare .edit.po files
60
+ .PHONY: extract-strings
61
+ extract-strings:
62
+ bundle exec rake gettext:find
63
+
64
+ .PHONY: tx-update
65
+ tx-update: extract-strings tx-pull update-po $(MOFILES) ## Download and merge translations from Transifex
66
+ git add ../locale
67
+ git commit -m "i18n - extracting new, pulling from tx"
68
+ @echo Changes commited!
69
+
70
+ .PHONY: clean
71
+ clean: ## Clean everything, removes *.edit.po, *.po.timestamp and *.pox files
72
+ rm -f $(EDITFILES) $(TIMESTAMPFILES) $(POXFILES)
73
+
74
+ .PHONY: help
75
+ help: ## This help message
76
+ @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
77
+
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
@@ -24,7 +24,6 @@ describe 'commands' do
24
24
  let(:cmd) { ['defaults', 'list'] }
25
25
 
26
26
  it 'prints all defaults' do
27
- header = 'Parameter,Value'
28
27
  default_values = {
29
28
  :organization_id => {
30
29
  :value => 3,
data/test/test_helper.rb CHANGED
@@ -11,7 +11,7 @@ SimpleCov.root Pathname.new(File.dirname(__FILE__) + "../../../")
11
11
  require 'minitest/autorun'
12
12
  require 'minitest/spec'
13
13
  require "minitest-spec-context"
14
- require "mocha/setup"
14
+ require "mocha/minitest"
15
15
 
16
16
  require 'hammer_cli'
17
17
  require 'hammer_cli/logger'
@@ -42,7 +42,7 @@ describe HammerCLI::Apipie::Command do
42
42
  let(:cmd_class) { CommandUnsupp.dup }
43
43
  let(:cmd) { cmd_class.new("unsupported", ctx) }
44
44
  it "should print help for unsupported command" do
45
- assert_match /.*Unfortunately the server does not support such operation.*/, cmd.help
45
+ assert_match(/.*Unfortunately the server does not support such operation.*/, cmd.help)
46
46
  end
47
47
 
48
48
  end
@@ -23,7 +23,7 @@ describe HammerCLI::Apipie::OptionDefinition do
23
23
 
24
24
  end
25
25
 
26
- let(:opt2) { HammerCLI::Apipie::OptionDefinition.new("--opt2", "OPT2", "&#39;OPT2&#39;", :referenced_resource => @referenced_resource) }
26
+ let(:opt2) { HammerCLI::Apipie::OptionDefinition.new("--opt2", "OPT2", "&#39;OPT2&#39;") }
27
27
 
28
28
  describe "Option Description should be converted" do
29
29
  it "should be converted" do
@@ -30,7 +30,7 @@ describe HammerCLI::ExceptionHandler do
30
30
  end
31
31
 
32
32
  it "should handle help request" do
33
- output.expects(:print_message).with(cmd.help, {}, verbosity: HammerCLI::V_QUIET)
33
+ output.expects(:print_message).with(cmd.help, {}, { verbosity: HammerCLI::V_QUIET })
34
34
  handler.handle_exception(Clamp::HelpWanted.new(cmd), :heading => heading)
35
35
 
36
36
  end
@@ -51,8 +51,8 @@ describe HammerCLI::ExceptionHandler do
51
51
  ex = RestClient::ResourceNotFound.new
52
52
  output.default_adapter = :silent
53
53
  handler.handle_exception(ex)
54
- assert_match /Using exception handler HammerCLI::ExceptionHandler#handle_not_found/, @log_output.readline.strip
55
- assert_match /ERROR Exception : (Resource )?Not Found/, @log_output.readline.strip
54
+ assert_match(/Using exception handler HammerCLI::ExceptionHandler#handle_not_found/, @log_output.readline.strip)
55
+ assert_match(/ERROR Exception : (Resource )?Not Found/, @log_output.readline.strip)
56
56
  end
57
57
 
58
58
  it "should print default prompts for standard missing arguments" do
@@ -20,13 +20,13 @@ describe HammerCLI::ShellHistory do
20
20
  describe "loading old history" do
21
21
 
22
22
  it "skips loading if the file does not exist" do
23
- history = HammerCLI::ShellHistory.new(new_file.path)
23
+ HammerCLI::ShellHistory.new(new_file.path)
24
24
 
25
25
  Readline::HISTORY.to_a.must_equal []
26
26
  end
27
27
 
28
28
  it "preseeds readline's history" do
29
- history = HammerCLI::ShellHistory.new(history_file.path)
29
+ HammerCLI::ShellHistory.new(history_file.path)
30
30
 
31
31
  Readline::HISTORY.to_a.must_equal ["line 1", "line 2"]
32
32
  end
@@ -4,7 +4,7 @@ require 'tempfile'
4
4
  describe Logging::LogEvent do
5
5
 
6
6
  describe '#initialize_logger' do
7
- let (:logger) { Logging::Logger.new(File.open('/dev/null')) }
7
+ let(:logger) { Logging::Logger.new(File.open('/dev/null')) }
8
8
 
9
9
  it "prints message to stderr when log dir can't be created" do
10
10
  log_dir = "/nonexistant/dir/logs"
@@ -12,7 +12,7 @@ describe Logging::LogEvent do
12
12
 
13
13
  HammerCLI::Settings.load({:log_dir => log_dir})
14
14
 
15
- out, err = capture_io do
15
+ _, err = capture_io do
16
16
  HammerCLI::Logger::initialize_logger(logger)
17
17
  end
18
18
 
@@ -63,8 +63,8 @@ describe HammerCLI::Options::OptionDefinition do
63
63
  context = {}
64
64
  cmd = TestDeprecatedOptionCmd.new("", context)
65
65
 
66
- out, err = capture_io { cmd.run(["--another-deprecated=VALUE"]) }
67
- err.must_match /Warning: Option --another-deprecated is deprecated. It is going to be removed/
66
+ _, err = capture_io { cmd.run(["--another-deprecated=VALUE"]) }
67
+ err.must_match(/Warning: Option --another-deprecated is deprecated. It is going to be removed/)
68
68
  context[:old_option].must_equal "VALUE"
69
69
  end
70
70
 
@@ -72,8 +72,8 @@ describe HammerCLI::Options::OptionDefinition do
72
72
  context = {}
73
73
  cmd = TestDeprecatedOptionCmd.new("", context)
74
74
 
75
- out, err = capture_io { cmd.run(["--deprecated=VALUE"]) }
76
- err.must_match /Warning: Option --deprecated is deprecated. Use --test-option instead/
75
+ _, err = capture_io { cmd.run(["--deprecated=VALUE"]) }
76
+ err.must_match(/Warning: Option --deprecated is deprecated. Use --test-option instead/)
77
77
  context[:test_option].must_equal "VALUE"
78
78
  end
79
79
 
@@ -20,10 +20,6 @@ describe HammerCLI::Options::Sources::SavedDefaults do
20
20
  @defaults.expects(:get_defaults).with('--test-multi1').returns(:first_value)
21
21
 
22
22
  current_result = {}
23
- expected_result = {
24
- :different_attr_name => 1,
25
- :multiple_switches_option => :first_value
26
- }
27
23
 
28
24
  @logger.expects(:info).with('Custom default value 1 was used for attribute --test')
29
25
  @logger.expects(:info).with('Custom default value first_value was used for attribute --test-multi1')
@@ -27,7 +27,7 @@ describe HammerCLI::Output::Adapter::Abstract do
27
27
  it "should filter formatters with incompatible features" do
28
28
 
29
29
  HammerCLI::Output::Formatters::FormatterLibrary.expects(:new).with({ :type => [] })
30
- adapter = adapter_class.new({}, {:type => [UnknownTestFormatter.new]})
30
+ adapter_class.new({}, {:type => [UnknownTestFormatter.new]})
31
31
  end
32
32
 
33
33
  it "should keep compatible formatters" do
@@ -35,7 +35,7 @@ describe HammerCLI::Output::Adapter::Abstract do
35
35
  HammerCLI::Output::Formatters::FormatterLibrary.expects(:new).with({ :type => [formatter] })
36
36
  # set :unknown tag to abstract
37
37
  adapter_class.any_instance.stubs(:features).returns([:unknown])
38
- adapter = adapter_class.new({}, {:type => [formatter]})
38
+ adapter_class.new({}, {:type => [formatter]})
39
39
  end
40
40
 
41
41
  it "should put serializers first" do
@@ -46,7 +46,7 @@ describe HammerCLI::Output::Adapter::Abstract do
46
46
  HammerCLI::Output::Formatters::FormatterLibrary.expects(:new).with({ :type => [formatter2, formatter1] })
47
47
  # set :unknown tag to abstract
48
48
  adapter_class.any_instance.stubs(:features).returns([:serialized])
49
- adapter = adapter_class.new({}, {:type => [formatter1, formatter2]})
49
+ adapter_class.new({}, {:type => [formatter1, formatter2]})
50
50
  end
51
51
 
52
52
 
@@ -24,28 +24,28 @@ describe HammerCLI::Output::Adapter::CSValues do
24
24
 
25
25
  it "should print column name" do
26
26
  out, err = capture_io { adapter.print_collection(fields, data) }
27
- out.must_match /.*Name,Started At.*/
28
- err.must_match //
27
+ out.must_match(/.*Name,Started At.*/)
28
+ err.must_match(//)
29
29
  end
30
30
 
31
31
  it "should print field value" do
32
32
  out, err = capture_io { adapter.print_collection(fields, data) }
33
- out.must_match /.*John Doe.*/
34
- err.must_match //
33
+ out.must_match(/.*John Doe.*/)
34
+ err.must_match(//)
35
35
  end
36
36
 
37
37
  it "does not print fields which data are missing from api by default" do
38
38
  fields << field_login
39
39
  out, err = capture_io { adapter.print_collection(fields, data) }
40
- out.wont_match /.*Login.*/
41
- err.must_match //
40
+ out.wont_match(/.*Login.*/)
41
+ err.must_match(//)
42
42
  end
43
43
 
44
44
  it "prints fields which data are missing from api when field has hide_missing flag set to false" do
45
45
  fields << field_missing
46
46
  out, err = capture_io { adapter.print_collection(fields, data) }
47
- out.must_match /.*Missing.*/
48
- err.must_match //
47
+ out.must_match(/.*Missing.*/)
48
+ err.must_match(//)
49
49
  end
50
50
 
51
51
  context "handle ids" do
@@ -59,14 +59,14 @@ describe HammerCLI::Output::Adapter::CSValues do
59
59
  }]}
60
60
 
61
61
  it "should ommit column of type Id by default" do
62
- out, err = capture_io { adapter.print_collection(fields, data) }
62
+ out, _ = capture_io { adapter.print_collection(fields, data) }
63
63
  out.wont_match(/.*Id.*/)
64
64
  out.wont_match(/.*2000,.*/)
65
65
  end
66
66
 
67
67
  it "should print column of type Id when --show-ids is set" do
68
68
  adapter = HammerCLI::Output::Adapter::CSValues.new( { :show_ids => true } )
69
- out, err = capture_io { adapter.print_collection(fields, data) }
69
+ out, _ = capture_io { adapter.print_collection(fields, data) }
70
70
  out.must_match(/.*Id.*/)
71
71
  end
72
72
  end
@@ -75,12 +75,12 @@ describe HammerCLI::Output::Adapter::CSValues do
75
75
  let(:empty_data) { HammerCLI::Output::RecordCollection.new [] }
76
76
 
77
77
  it "should print headers by default" do
78
- out, err = capture_io { adapter.print_collection(fields, data) }
78
+ out, _ = capture_io { adapter.print_collection(fields, data) }
79
79
  out.must_match(/.*Name.*/)
80
80
  end
81
81
 
82
82
  it "should print headers by default even if there is no data" do
83
- out, err = capture_io { adapter.print_collection(fields, empty_data) }
83
+ out, _ = capture_io { adapter.print_collection(fields, empty_data) }
84
84
  out.must_match(/.*Name.*/)
85
85
  end
86
86
 
@@ -127,14 +127,14 @@ describe HammerCLI::Output::Adapter::CSValues do
127
127
 
128
128
  it "should print column names" do
129
129
  out, err = capture_io { adapter.print_collection(fields, data) }
130
- out.must_match /.*Demographics::Age,Demographics::Gender,Biometrics::Weight,Biometrics::Height*/
131
- err.must_match //
130
+ out.must_match(/.*Demographics::Age,Demographics::Gender,Biometrics::Weight,Biometrics::Height*/)
131
+ err.must_match(//)
132
132
  end
133
133
 
134
134
  it "should print data" do
135
135
  out, err = capture_io { adapter.print_collection(fields, data) }
136
- out.must_match /.*2000,22,m,123,155*/
137
- err.must_match //
136
+ out.must_match(/.*2000,22,m,123,155*/)
137
+ err.must_match(//)
138
138
  end
139
139
  end
140
140
 
@@ -169,7 +169,7 @@ describe HammerCLI::Output::Adapter::CSValues do
169
169
  lines = out.split("\n")
170
170
  lines[0].must_equal 'Name,Started At,Items::Item Name::1,Items::Item Quantity::1,Items::Item Name::2,Items::Item Quantity::2'
171
171
 
172
- err.must_match //
172
+ err.must_match(//)
173
173
  end
174
174
 
175
175
  it "should print collection data" do
@@ -179,7 +179,7 @@ describe HammerCLI::Output::Adapter::CSValues do
179
179
  lines[1].must_equal 'John Doe,2000,hammer,100,"",""'
180
180
  lines[2].must_equal 'Jane Roe,2001,cleaver,1,sledge,50'
181
181
 
182
- err.must_match //
182
+ err.must_match(//)
183
183
  end
184
184
 
185
185
  it "should handle empty collection" do
@@ -188,7 +188,7 @@ describe HammerCLI::Output::Adapter::CSValues do
188
188
 
189
189
  lines[0].must_equal 'Name,Started At,Items'
190
190
 
191
- err.must_match //
191
+ err.must_match(//)
192
192
  end
193
193
 
194
194
  end
@@ -202,7 +202,7 @@ describe HammerCLI::Output::Adapter::CSValues do
202
202
  end
203
203
 
204
204
  adapter = HammerCLI::Output::Adapter::CSValues.new({}, { :Field => [ DotFormatter.new ]})
205
- out, err = capture_io { adapter.print_collection(fields, data) }
205
+ out, _ = capture_io { adapter.print_collection(fields, data) }
206
206
  out.must_match(/.*-DOT-.*/)
207
207
  end
208
208
 
@@ -215,7 +215,7 @@ describe HammerCLI::Output::Adapter::CSValues do
215
215
 
216
216
  adapter = HammerCLI::Output::Adapter::CSValues.new({}, { :Field => [ NilFormatter.new ]})
217
217
  nil_data = HammerCLI::Output::RecordCollection.new [{ :name => nil }]
218
- out, err = capture_io { adapter.print_collection([field_name], nil_data) }
218
+ out, _ = capture_io { adapter.print_collection([field_name], nil_data) }
219
219
  out.must_match(/.*NIL.*/)
220
220
  end
221
221
  end
@@ -94,7 +94,7 @@ describe HammerCLI::Output::Adapter::Table do
94
94
  }
95
95
 
96
96
  it "should ommit column of type Id by default" do
97
- out, err = capture_io { adapter.print_collection(fields, data) }
97
+ out, _ = capture_io { adapter.print_collection(fields, data) }
98
98
  out.wont_match(/.*ID.*/)
99
99
  end
100
100
 
@@ -110,7 +110,7 @@ describe HammerCLI::Output::Adapter::Table do
110
110
 
111
111
  it "should print column of type Id when --show-ids is set" do
112
112
  adapter = HammerCLI::Output::Adapter::Table.new( { :show_ids => true } )
113
- out, err = capture_io { adapter.print_collection(fields, data) }
113
+ out, _ = capture_io { adapter.print_collection(fields, data) }
114
114
  out.must_match(/.*ID.*/)
115
115
  end
116
116
 
@@ -128,12 +128,12 @@ describe HammerCLI::Output::Adapter::Table do
128
128
 
129
129
  context "handle headers" do
130
130
  it "should print headers by default" do
131
- out, err = capture_io { adapter.print_collection(fields, data) }
131
+ out, _ = capture_io { adapter.print_collection(fields, data) }
132
132
  out.must_match(/.*NAME.*/)
133
133
  end
134
134
 
135
135
  it "should print headers by default even if there is no data" do
136
- out, err = capture_io { adapter.print_collection(fields, empty_data) }
136
+ out, _ = capture_io { adapter.print_collection(fields, empty_data) }
137
137
  out.must_match(/.*NAME.*/)
138
138
  end
139
139
 
@@ -353,7 +353,7 @@ describe HammerCLI::Output::Adapter::Table do
353
353
  end
354
354
 
355
355
  adapter = HammerCLI::Output::Adapter::Table.new({}, { :Field => [ DotFormatter.new ]})
356
- out, err = capture_io { adapter.print_collection(fields, data) }
356
+ out, _ = capture_io { adapter.print_collection(fields, data) }
357
357
  out.must_match(/.*-DOT-.*/)
358
358
  end
359
359
 
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: 3.5.1
4
+ version: 3.7.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: 2023-02-28 00:00:00.000000000 Z
12
+ date: 2023-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -17,20 +17,20 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.1'
20
+ version: 1.3.1
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.0
23
+ version: 2.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '1.1'
30
+ version: 1.3.1
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.0
33
+ version: 2.0.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: logging
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -174,8 +174,8 @@ extra_rdoc_files:
174
174
  - doc/writing_a_plugin.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
@@ -294,6 +294,7 @@ files:
294
294
  - lib/hammer_cli/utils.rb
295
295
  - lib/hammer_cli/verbosity.rb
296
296
  - lib/hammer_cli/version.rb
297
+ - locale/Makefile.def
297
298
  - locale/ca/LC_MESSAGES/hammer-cli.mo
298
299
  - locale/de/LC_MESSAGES/hammer-cli.mo
299
300
  - locale/en/LC_MESSAGES/hammer-cli.mo
@@ -387,7 +388,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
387
388
  requirements:
388
389
  - - ">="
389
390
  - !ruby/object:Gem::Version
390
- version: '0'
391
+ version: '2.7'
391
392
  required_rubygems_version: !ruby/object:Gem::Requirement
392
393
  requirements:
393
394
  - - ">="
@@ -399,24 +400,17 @@ signing_key:
399
400
  specification_version: 4
400
401
  summary: Universal command-line interface
401
402
  test_files:
402
- - test/functional/defaults_test.rb
403
- - test/functional/help_test.rb
404
403
  - test/functional/nil_values_test.rb
405
404
  - test/functional/test_helper.rb
406
- - test/unit/abstract_test.rb
405
+ - test/functional/help_test.rb
406
+ - test/functional/defaults_test.rb
407
407
  - test/unit/apipie/api_connection_test.rb
408
- - test/unit/apipie/command_test.rb
409
408
  - test/unit/apipie/option_builder_test.rb
410
- - test/unit/apipie/option_definition_test.rb
411
409
  - test/unit/apipie/test_helper.rb
412
- - test/unit/bash_test.rb
410
+ - test/unit/apipie/command_test.rb
411
+ - test/unit/apipie/option_definition_test.rb
413
412
  - test/unit/ca_cert_manager_test.rb
414
- - test/unit/command_extensions_test.rb
415
- - test/unit/completer_test.rb
416
413
  - test/unit/connection_test.rb
417
- - test/unit/csv_parser_test.rb
418
- - test/unit/defaults_test.rb
419
- - test/unit/exception_handler_test.rb
420
414
  - test/unit/fixtures/apipie/architectures.json
421
415
  - test/unit/fixtures/apipie/documented.json
422
416
  - test/unit/fixtures/certs/ca_cert.pem
@@ -425,36 +419,30 @@ test_files:
425
419
  - test/unit/fixtures/defaults/defaults_dashed.yml
426
420
  - test/unit/fixtures/json_input/invalid.json
427
421
  - test/unit/fixtures/json_input/valid.json
428
- - test/unit/help/builder_test.rb
429
422
  - test/unit/help/definition/abstract_item_test.rb
430
423
  - test/unit/help/definition/list_test.rb
431
424
  - test/unit/help/definition/note_test.rb
432
425
  - test/unit/help/definition/section_test.rb
433
426
  - test/unit/help/definition/text_test.rb
427
+ - test/unit/help/builder_test.rb
434
428
  - test/unit/help/definition_test.rb
435
429
  - test/unit/help/text_builder_test.rb
436
- - test/unit/history_test.rb
437
- - test/unit/i18n_test.rb
438
- - test/unit/logger_test.rb
439
- - test/unit/main_test.rb
440
430
  - test/unit/messages_test.rb
441
- - test/unit/modules_test.rb
442
- - test/unit/option_builder_test.rb
443
- - test/unit/options/matcher_test.rb
444
- - test/unit/options/normalizers_test.rb
445
431
  - test/unit/options/option_collector_test.rb
446
- - test/unit/options/option_definition_test.rb
447
- - test/unit/options/option_family_test.rb
448
432
  - test/unit/options/processor_list_test.rb
449
433
  - test/unit/options/sources/command_line_test.rb
450
434
  - test/unit/options/sources/saved_defaults_test.rb
451
435
  - test/unit/options/validators/dsl_test.rb
452
- - test/unit/output/adapter/abstract_test.rb
436
+ - test/unit/options/matcher_test.rb
437
+ - test/unit/options/normalizers_test.rb
438
+ - test/unit/options/option_family_test.rb
439
+ - test/unit/options/option_definition_test.rb
453
440
  - test/unit/output/adapter/base_test.rb
454
- - test/unit/output/adapter/csv_test.rb
455
441
  - test/unit/output/adapter/json_test.rb
456
- - test/unit/output/adapter/table_test.rb
457
442
  - test/unit/output/adapter/yaml_test.rb
443
+ - test/unit/output/adapter/abstract_test.rb
444
+ - test/unit/output/adapter/csv_test.rb
445
+ - test/unit/output/adapter/table_test.rb
458
446
  - test/unit/output/definition_test.rb
459
447
  - test/unit/output/dsl_test.rb
460
448
  - test/unit/output/field_filter_test.rb
@@ -462,7 +450,20 @@ test_files:
462
450
  - test/unit/output/formatters_test.rb
463
451
  - test/unit/output/output_test.rb
464
452
  - test/unit/output/record_collection_test.rb
465
- - test/unit/settings_test.rb
466
453
  - test/unit/test_helper.rb
454
+ - test/unit/abstract_test.rb
455
+ - test/unit/command_extensions_test.rb
456
+ - test/unit/defaults_test.rb
457
+ - test/unit/i18n_test.rb
458
+ - test/unit/main_test.rb
459
+ - test/unit/modules_test.rb
460
+ - test/unit/settings_test.rb
461
+ - test/unit/exception_handler_test.rb
462
+ - test/unit/history_test.rb
463
+ - test/unit/logger_test.rb
464
+ - test/unit/bash_test.rb
465
+ - test/unit/completer_test.rb
466
+ - test/unit/csv_parser_test.rb
467
+ - test/unit/option_builder_test.rb
467
468
  - test/unit/utils_test.rb
468
469
  - test/test_helper.rb