hammer_cli 3.6.0 → 3.7.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/config/cli_config.template.yml +3 -3
- data/doc/release_notes.md +9 -0
- data/lib/hammer_cli/abstract.rb +1 -1
- data/lib/hammer_cli/defaults_commands.rb +0 -1
- data/lib/hammer_cli/help/builder.rb +6 -6
- data/lib/hammer_cli/logger.rb +2 -2
- data/lib/hammer_cli/modules.rb +1 -1
- data/lib/hammer_cli/options/normalizers.rb +2 -2
- data/lib/hammer_cli/options/validators/dsl.rb +1 -1
- data/lib/hammer_cli/output/adapter/csv.rb +0 -1
- data/lib/hammer_cli/output/dsl.rb +1 -1
- data/lib/hammer_cli/output/fields.rb +1 -1
- data/lib/hammer_cli/output/formatters.rb +4 -4
- data/lib/hammer_cli/ssloptions.rb +3 -3
- data/lib/hammer_cli/subcommand.rb +1 -0
- data/lib/hammer_cli/utils.rb +0 -12
- data/lib/hammer_cli/version.rb +1 -1
- data/test/functional/defaults_test.rb +0 -1
- data/test/unit/apipie/command_test.rb +1 -1
- data/test/unit/apipie/option_definition_test.rb +1 -1
- data/test/unit/exception_handler_test.rb +3 -3
- data/test/unit/history_test.rb +2 -2
- data/test/unit/logger_test.rb +2 -2
- data/test/unit/options/option_definition_test.rb +4 -4
- data/test/unit/options/sources/saved_defaults_test.rb +0 -4
- data/test/unit/output/adapter/abstract_test.rb +3 -3
- data/test/unit/output/adapter/csv_test.rb +21 -21
- data/test/unit/output/adapter/table_test.rb +5 -5
- metadata +35 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c8ba63d251f23a5e6005d7adcab02b5045639060c1bd5a3a02741e6d5561945
|
4
|
+
data.tar.gz: b94fd6c3342e7c8b06efeb7dfe754f449cd0ce76b62cc7cafadf13031fbf2f94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
#
|
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
|
-
|
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,5 +1,14 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
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
|
+
|
3
12
|
### 3.6.0 (2023-02-23)
|
4
13
|
* Update apipie-bindings to 0.6.0
|
5
14
|
* Include makefile.def in the gem
|
data/lib/hammer_cli/abstract.rb
CHANGED
@@ -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
|
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
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
58
|
-
|
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
|
-
|
66
|
+
line label
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
data/lib/hammer_cli/logger.rb
CHANGED
@@ -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
|
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
|
71
|
+
rescue ArgumentError
|
72
72
|
$stderr.puts _("File %s not writeable, won't log anything to the file!") % filename
|
73
73
|
end
|
74
74
|
|
data/lib/hammer_cli/modules.rb
CHANGED
@@ -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
|
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
|
-
::
|
371
|
+
::Time.parse(date).iso8601
|
372
372
|
rescue ArgumentError
|
373
373
|
raise ArgumentError, _("'%s' is not a valid date.") % date
|
374
374
|
end
|
@@ -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
|
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
|
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,
|
88
|
-
|
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,
|
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
|
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
|
77
|
-
rescue SystemCallError
|
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
|
data/lib/hammer_cli/utils.rb
CHANGED
@@ -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?
|
data/lib/hammer_cli/version.rb
CHANGED
@@ -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
|
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", "'OPT2'"
|
26
|
+
let(:opt2) { HammerCLI::Apipie::OptionDefinition.new("--opt2", "OPT2", "'OPT2'") }
|
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
|
55
|
-
assert_match
|
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
|
data/test/unit/history_test.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
29
|
+
HammerCLI::ShellHistory.new(history_file.path)
|
30
30
|
|
31
31
|
Readline::HISTORY.to_a.must_equal ["line 1", "line 2"]
|
32
32
|
end
|
data/test/unit/logger_test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'tempfile'
|
|
4
4
|
describe Logging::LogEvent do
|
5
5
|
|
6
6
|
describe '#initialize_logger' do
|
7
|
-
let
|
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
|
-
|
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
|
-
|
67
|
-
err.must_match
|
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
|
-
|
76
|
-
err.must_match
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
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
|
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,
|
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,
|
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,
|
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,
|
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
|
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
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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.
|
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-
|
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:
|
20
|
+
version: 1.3.1
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
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:
|
30
|
+
version: 1.3.1
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
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
|
@@ -388,7 +388,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
388
388
|
requirements:
|
389
389
|
- - ">="
|
390
390
|
- !ruby/object:Gem::Version
|
391
|
-
version: '
|
391
|
+
version: '2.7'
|
392
392
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
393
393
|
requirements:
|
394
394
|
- - ">="
|
@@ -400,25 +400,17 @@ signing_key:
|
|
400
400
|
specification_version: 4
|
401
401
|
summary: Universal command-line interface
|
402
402
|
test_files:
|
403
|
-
- test/functional/defaults_test.rb
|
404
|
-
- test/functional/help_test.rb
|
405
403
|
- test/functional/nil_values_test.rb
|
406
404
|
- test/functional/test_helper.rb
|
407
|
-
- test/
|
408
|
-
- test/
|
405
|
+
- test/functional/help_test.rb
|
406
|
+
- test/functional/defaults_test.rb
|
409
407
|
- test/unit/apipie/api_connection_test.rb
|
410
|
-
- test/unit/apipie/command_test.rb
|
411
408
|
- test/unit/apipie/option_builder_test.rb
|
412
|
-
- test/unit/apipie/option_definition_test.rb
|
413
409
|
- test/unit/apipie/test_helper.rb
|
414
|
-
- test/unit/
|
410
|
+
- test/unit/apipie/command_test.rb
|
411
|
+
- test/unit/apipie/option_definition_test.rb
|
415
412
|
- test/unit/ca_cert_manager_test.rb
|
416
|
-
- test/unit/command_extensions_test.rb
|
417
|
-
- test/unit/completer_test.rb
|
418
413
|
- test/unit/connection_test.rb
|
419
|
-
- test/unit/csv_parser_test.rb
|
420
|
-
- test/unit/defaults_test.rb
|
421
|
-
- test/unit/exception_handler_test.rb
|
422
414
|
- test/unit/fixtures/apipie/architectures.json
|
423
415
|
- test/unit/fixtures/apipie/documented.json
|
424
416
|
- test/unit/fixtures/certs/ca_cert.pem
|
@@ -427,36 +419,30 @@ test_files:
|
|
427
419
|
- test/unit/fixtures/defaults/defaults_dashed.yml
|
428
420
|
- test/unit/fixtures/json_input/invalid.json
|
429
421
|
- test/unit/fixtures/json_input/valid.json
|
430
|
-
- test/unit/help/builder_test.rb
|
431
422
|
- test/unit/help/definition/abstract_item_test.rb
|
432
423
|
- test/unit/help/definition/list_test.rb
|
433
424
|
- test/unit/help/definition/note_test.rb
|
434
425
|
- test/unit/help/definition/section_test.rb
|
435
426
|
- test/unit/help/definition/text_test.rb
|
427
|
+
- test/unit/help/builder_test.rb
|
436
428
|
- test/unit/help/definition_test.rb
|
437
429
|
- test/unit/help/text_builder_test.rb
|
438
|
-
- test/unit/history_test.rb
|
439
|
-
- test/unit/i18n_test.rb
|
440
|
-
- test/unit/logger_test.rb
|
441
|
-
- test/unit/main_test.rb
|
442
430
|
- test/unit/messages_test.rb
|
443
|
-
- test/unit/modules_test.rb
|
444
|
-
- test/unit/option_builder_test.rb
|
445
|
-
- test/unit/options/matcher_test.rb
|
446
|
-
- test/unit/options/normalizers_test.rb
|
447
431
|
- test/unit/options/option_collector_test.rb
|
448
|
-
- test/unit/options/option_definition_test.rb
|
449
|
-
- test/unit/options/option_family_test.rb
|
450
432
|
- test/unit/options/processor_list_test.rb
|
451
433
|
- test/unit/options/sources/command_line_test.rb
|
452
434
|
- test/unit/options/sources/saved_defaults_test.rb
|
453
435
|
- test/unit/options/validators/dsl_test.rb
|
454
|
-
- test/unit/
|
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
|
455
440
|
- test/unit/output/adapter/base_test.rb
|
456
|
-
- test/unit/output/adapter/csv_test.rb
|
457
441
|
- test/unit/output/adapter/json_test.rb
|
458
|
-
- test/unit/output/adapter/table_test.rb
|
459
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
|
460
446
|
- test/unit/output/definition_test.rb
|
461
447
|
- test/unit/output/dsl_test.rb
|
462
448
|
- test/unit/output/field_filter_test.rb
|
@@ -464,6 +450,20 @@ test_files:
|
|
464
450
|
- test/unit/output/formatters_test.rb
|
465
451
|
- test/unit/output/output_test.rb
|
466
452
|
- test/unit/output/record_collection_test.rb
|
467
|
-
- test/unit/settings_test.rb
|
468
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
|
469
468
|
- test/unit/utils_test.rb
|
469
|
+
- test/test_helper.rb
|