hammer_cli 3.1.1 → 3.2.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/doc/release_notes.md +4 -1
- data/lib/hammer_cli/options/normalizers.rb +3 -5
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f58fd9560500629473f107167076c735526a1a503fa5c7676d7c0da2dd160e
|
4
|
+
data.tar.gz: cf66853b504d0081194fa88192cb6fd7fb007270c26b81276be7ab64ba89aa5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e8838aca5dc25c9374a0747f8528f9594a79f0554e1ddff7728378a688458c835e7cab898abf85c06a37802aa019f8d1eda4883fcef8e1639d23e655eca3217
|
7
|
+
data.tar.gz: 3f25216e7fc377aad69858ecfa602206da549ae2d214df29990da055d91459088f2a1c95379560af254c755bc5838e11934e6a28bd1109c503390513b9cf4ebf
|
data/doc/release_notes.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
-
### 3.
|
3
|
+
### 3.2.0 (2022-02-10)
|
4
4
|
* Fix fr translation ([PR #358](https://github.com/theforeman/hammer-cli/pull/358)), [#34204](http://projects.theforeman.org/issues/34204)
|
5
|
+
* Add missing_args_error_result test helper ([PR #357](https://github.com/theforeman/hammer-cli/pull/357))
|
6
|
+
* Allow explicit strings in key=value options ([PR #356](https://github.com/theforeman/hammer-cli/pull/356)), [#34079](http://projects.theforeman.org/issues/34079)
|
7
|
+
* Bump to 3.2.0-develop
|
5
8
|
|
6
9
|
### 3.1.0 (2021-11-10)
|
7
10
|
* Remove a space in hammer's shebang, [#33810](http://projects.theforeman.org/issues/33810)
|
@@ -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
|
|
@@ -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,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.2.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: 2022-02-
|
12
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|