hammer_cli 3.1.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes.md +10 -0
- data/lib/hammer_cli/options/normalizers.rb +3 -5
- data/lib/hammer_cli/shell.rb +3 -2
- data/lib/hammer_cli/testing/command_assertions.rb +21 -0
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/test/unit/options/normalizers_test.rb +26 -10
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a4ae8103129f5454bb936dbb55071ee6710e70f7ea90404d8f32f024d006b18
|
4
|
+
data.tar.gz: 928d97708685626852128ba704d638a7c02e5119d122cd658ae8421780f73854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b9e62f788e6f7e70a72a4f588d955cc9fd9b690e7ec074098f52805a61a721294a51c35fb92202c4dda4c18752e1694409ebaa67285be5bc350ae20cf47ff51
|
7
|
+
data.tar.gz: ea53be858296c5a99db9c2cc11ce9e1916b807863972dec3da6412633d51019cbdfc5758dfb37a20aca55e81d755f7cd43a018c5b881e399811c80c7f7f92396
|
data/doc/release_notes.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
+
### 3.3.0 (2022-05-10)
|
4
|
+
* Fix hammer shell with pipe as stdin ([PR #360](https://github.com/theforeman/hammer-cli/pull/360)), [#34724](http://projects.theforeman.org/issues/34724)
|
5
|
+
* Bump to 3.3.0-develop
|
6
|
+
|
7
|
+
### 3.2.0 (2022-02-10)
|
8
|
+
* Fix fr translation ([PR #358](https://github.com/theforeman/hammer-cli/pull/358)), [#34204](http://projects.theforeman.org/issues/34204)
|
9
|
+
* Add missing_args_error_result test helper ([PR #357](https://github.com/theforeman/hammer-cli/pull/357))
|
10
|
+
* Allow explicit strings in key=value options ([PR #356](https://github.com/theforeman/hammer-cli/pull/356)), [#34079](http://projects.theforeman.org/issues/34079)
|
11
|
+
* Bump to 3.2.0-develop
|
12
|
+
|
3
13
|
### 3.1.0 (2021-11-10)
|
4
14
|
* Remove a space in hammer's shebang, [#33810](http://projects.theforeman.org/issues/33810)
|
5
15
|
* Revert fix rake version
|
@@ -104,15 +104,13 @@ module HammerCLI
|
|
104
104
|
|
105
105
|
def strip_value(value)
|
106
106
|
if value.is_a? Array
|
107
|
-
value.map
|
108
|
-
strip_chars(item.strip, '"\'')
|
109
|
-
end
|
107
|
+
value.map(&:strip)
|
110
108
|
elsif value.is_a? Hash
|
111
109
|
value.map do |key, val|
|
112
|
-
[strip_chars(key.strip, '"\''),
|
110
|
+
[strip_chars(key.strip, '"\''), val.strip]
|
113
111
|
end.to_h
|
114
112
|
else
|
115
|
-
|
113
|
+
value.strip
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
data/lib/hammer_cli/shell.rb
CHANGED
@@ -86,7 +86,7 @@ module HammerCLI
|
|
86
86
|
Readline.completer_word_break_characters = ' ='
|
87
87
|
Readline.completion_proc = complete_proc
|
88
88
|
|
89
|
-
stty_save = `stty -g`.chomp
|
89
|
+
stty_save = `stty -g`.chomp if $stdin.tty?
|
90
90
|
|
91
91
|
history = ShellHistory.new(Settings.get(:ui, :history_file) || DEFAULT_HISTORY_FILE)
|
92
92
|
|
@@ -102,7 +102,8 @@ module HammerCLI
|
|
102
102
|
rescue Interrupt; end
|
103
103
|
|
104
104
|
puts
|
105
|
-
|
105
|
+
# Restore
|
106
|
+
system('stty', stty_save) if $stdin.tty?
|
106
107
|
HammerCLI::EX_OK
|
107
108
|
end
|
108
109
|
|
@@ -94,6 +94,20 @@ module HammerCLI
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
def missing_args_error(command, opts, heading = nil)
|
98
|
+
opts = Array(opts).map { |o| "'#{o}'" }.join(', ')
|
99
|
+
message = " Missing arguments for #{opts}."
|
100
|
+
if heading.nil?
|
101
|
+
["Could not #{command[-1]} the #{command[-2]}:",
|
102
|
+
message,
|
103
|
+
''].join("\n")
|
104
|
+
else
|
105
|
+
["#{heading}:",
|
106
|
+
message,
|
107
|
+
''].join("\n")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
97
111
|
def usage_error_result(command, message, heading=nil)
|
98
112
|
expected_result = CommandExpectation.new
|
99
113
|
expected_result.expected_err = usage_error(command, message, heading)
|
@@ -115,6 +129,13 @@ module HammerCLI
|
|
115
129
|
expected_result
|
116
130
|
end
|
117
131
|
|
132
|
+
def missing_args_error_result(command, opts, heading = nil)
|
133
|
+
expected_result = CommandExpectation.new
|
134
|
+
expected_result.expected_err = missing_args_error(command, opts, heading)
|
135
|
+
expected_result.expected_exit_code = HammerCLI::EX_USAGE
|
136
|
+
expected_result
|
137
|
+
end
|
138
|
+
|
118
139
|
def success_result(message)
|
119
140
|
CommandExpectation.new(message)
|
120
141
|
end
|
data/lib/hammer_cli/version.rb
CHANGED
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
|
@@ -177,16 +177,20 @@ describe HammerCLI::Options::Normalizers do
|
|
177
177
|
formatter.format("a= 1 , b = 2 ,c =3").must_equal({'a' => '1', 'b' => '2', 'c' => '3'})
|
178
178
|
end
|
179
179
|
|
180
|
-
it
|
181
|
-
formatter.format("a= ' 1 ' , b =' 2',c ='3'").must_equal({'a' => ' 1 ', 'b' => ' 2', 'c' => '3'})
|
180
|
+
it 'should parse a comma separated string with spaces using single quotes' do
|
181
|
+
formatter.format("a= ' 1 ' , b =' 2',c ='3'").must_equal({ 'a' => "' 1 '", 'b' => "' 2'", 'c' => "'3'" })
|
182
182
|
end
|
183
183
|
|
184
|
-
it
|
185
|
-
formatter.format(
|
184
|
+
it 'should parse a comma separated string with spaces using double quotes' do
|
185
|
+
formatter.format('a= " 1 " , b =" 2",c ="3"').must_equal({ 'a' => '" 1 "', 'b' => '" 2"', 'c' => '"3"' })
|
186
186
|
end
|
187
187
|
|
188
|
-
it
|
189
|
-
formatter.format("a=1,b='2=2',c=3").must_equal({'a' => '1', 'b' => '2=2', 'c' => '3'})
|
188
|
+
it 'should deal with equal sign in string value' do
|
189
|
+
formatter.format("a=1,b='2=2',c=3").must_equal({ 'a' => '1', 'b' => "'2=2'", 'c' => '3' })
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'should deal with equal sign in value' do
|
193
|
+
formatter.format('a=1,b=2=2,c=3').must_equal({ 'a' => '1', 'b' => '2=2', 'c' => '3' })
|
190
194
|
end
|
191
195
|
|
192
196
|
it "should parse arrays" do
|
@@ -197,12 +201,20 @@ describe HammerCLI::Options::Normalizers do
|
|
197
201
|
formatter.format("a=1,b=[1, 2, 3],c=3").must_equal({'a' => '1', 'b' => ['1', '2', '3'], 'c' => '3'})
|
198
202
|
end
|
199
203
|
|
200
|
-
it
|
201
|
-
formatter.format("a=1,b=['1 1', ' 2 ', ' 3 3'],c=3").must_equal(
|
204
|
+
it 'should parse arrays with spaces using by single quotes' do
|
205
|
+
formatter.format("a=1,b=['1 1', ' 2 ', ' 3 3'],c=3").must_equal(
|
206
|
+
{ 'a' => '1', 'b' => ["'1 1'", "' 2 '", "' 3 3'"], 'c' => '3' }
|
207
|
+
)
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should parse arrays with spaces using by double quotes' do
|
211
|
+
formatter.format('a=1,b=["1 1", " 2 ", " 3 3"],c=3').must_equal(
|
212
|
+
{ 'a' => '1', 'b' => ['"1 1"', '" 2 "', '" 3 3"'], 'c' => '3' }
|
213
|
+
)
|
202
214
|
end
|
203
215
|
|
204
|
-
it
|
205
|
-
formatter.format(
|
216
|
+
it 'should parse arrays with spaces' do
|
217
|
+
formatter.format('a=1,b=[1 1, 2 , 3 3],c=3').must_equal({ 'a' => '1', 'b' => ['1 1', '2', '3 3'], 'c' => '3' })
|
206
218
|
end
|
207
219
|
|
208
220
|
it "should parse array with one item" do
|
@@ -226,6 +238,10 @@ describe HammerCLI::Options::Normalizers do
|
|
226
238
|
it "should parse a comma separated string 2" do
|
227
239
|
proc { formatter.format("a=1,b,c=3") }.must_raise ArgumentError
|
228
240
|
end
|
241
|
+
|
242
|
+
it 'should parse explicit strings' do
|
243
|
+
formatter.format('name="*"').must_equal({ 'name' => '"*"' })
|
244
|
+
end
|
229
245
|
end
|
230
246
|
|
231
247
|
describe 'json format' do
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Bačovský
|
8
8
|
- Tomáš Strachota
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
@@ -135,17 +135,17 @@ dependencies:
|
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.5.0
|
139
139
|
type: :runtime
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: 0.5.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
|
@@ -163,6 +163,7 @@ extra_rdoc_files:
|
|
163
163
|
- doc/option_normalizers.md
|
164
164
|
- doc/writing_a_plugin.md
|
165
165
|
- doc/installation_source.md
|
166
|
+
- doc/creating_commands.md
|
166
167
|
- doc/release_notes.md
|
167
168
|
- doc/commands_extension.md
|
168
169
|
- doc/commands_modification.md
|
@@ -172,10 +173,9 @@ extra_rdoc_files:
|
|
172
173
|
- doc/installation_rpm.md
|
173
174
|
- doc/output.md
|
174
175
|
- doc/review_checklist.md
|
175
|
-
- doc/creating_commands.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
|
@@ -379,7 +379,7 @@ homepage: https://github.com/theforeman/hammer-cli
|
|
379
379
|
licenses:
|
380
380
|
- GPL-3.0
|
381
381
|
metadata: {}
|
382
|
-
post_install_message:
|
382
|
+
post_install_message:
|
383
383
|
rdoc_options: []
|
384
384
|
require_paths:
|
385
385
|
- lib
|
@@ -395,7 +395,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
395
395
|
version: '0'
|
396
396
|
requirements: []
|
397
397
|
rubygems_version: 3.1.2
|
398
|
-
signing_key:
|
398
|
+
signing_key:
|
399
399
|
specification_version: 4
|
400
400
|
summary: Universal command-line interface
|
401
401
|
test_files:
|
@@ -414,8 +414,8 @@ test_files:
|
|
414
414
|
- test/unit/connection_test.rb
|
415
415
|
- test/unit/csv_parser_test.rb
|
416
416
|
- test/unit/defaults_test.rb
|
417
|
-
- test/unit/fixtures/apipie/architectures.json
|
418
417
|
- test/unit/fixtures/apipie/documented.json
|
418
|
+
- test/unit/fixtures/apipie/architectures.json
|
419
419
|
- test/unit/fixtures/certs/ca_cert.pem
|
420
420
|
- test/unit/fixtures/certs/non_ca_cert.pem
|
421
421
|
- test/unit/fixtures/defaults/defaults.yml
|
@@ -443,9 +443,9 @@ test_files:
|
|
443
443
|
- test/unit/options/sources/command_line_test.rb
|
444
444
|
- test/unit/options/sources/saved_defaults_test.rb
|
445
445
|
- test/unit/options/validators/dsl_test.rb
|
446
|
-
- test/unit/options/normalizers_test.rb
|
447
446
|
- test/unit/options/option_family_test.rb
|
448
447
|
- test/unit/options/option_definition_test.rb
|
448
|
+
- test/unit/options/normalizers_test.rb
|
449
449
|
- test/unit/output/adapter/abstract_test.rb
|
450
450
|
- test/unit/output/adapter/base_test.rb
|
451
451
|
- test/unit/output/adapter/csv_test.rb
|