hammer_cli 3.1.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b85ac5a195550a8e7a09c1f9be837e8ff6fb20a2beec7d17be3a74ff1b18a6d4
4
- data.tar.gz: f07cb34217d8c07e9d93884ad49142a3a9e28121bc0127d69eab9db0052b00e1
3
+ metadata.gz: 19ccf9a99763e1aabeaafef875ee962c17dea4247848c2c72f55f02ee49c0556
4
+ data.tar.gz: 8ed4b36598e80f4ab0a4546aa28914860bfc847ef303b58180df33da1450428f
5
5
  SHA512:
6
- metadata.gz: d680f551580f46e4b108e8350b62da4fc724405a02181d25a67627cca1d674e5b8ddef9badd1a3f8dc67990f567f035c1351b73d5e4e92aa510f532f750fdc16
7
- data.tar.gz: f4515582c5297748b00a81c41ec2d39e7757e58dfc41cf77cd57c5b0044fd733594cc8bf62fbe44ac252bc3d65a06ef48a7916ad9f32a39a040d6a3ad395f078
6
+ metadata.gz: 378a341cfe23d45752298fcf586772b60e838b5602ee4e89d4eb97c4c92e059c14742d37faa3ba81dfe6d97f8553d1df6afeb328b2c8acda81a01751b6180d58
7
+ data.tar.gz: bcb5ede4af035343c4fae584d48b761d8c948104091835a49b875d0f6f105e422adae4f127d602ef5ba1760aeb4f4a24568cd3a4a16d30ec27d7646c7f8fed4e
data/doc/release_notes.md CHANGED
@@ -1,7 +1,17 @@
1
1
  Release notes
2
2
  =============
3
- ### 3.1.1 (2022-02-01)
3
+ ### 3.4.0 (2022-08-09)
4
+ * Bump to 3.4.0-develop
5
+
6
+ ### 3.3.0 (2022-05-10)
7
+ * Fix hammer shell with pipe as stdin ([PR #360](https://github.com/theforeman/hammer-cli/pull/360)), [#34724](http://projects.theforeman.org/issues/34724)
8
+ * Bump to 3.3.0-develop
9
+
10
+ ### 3.2.0 (2022-02-10)
4
11
  * Fix fr translation ([PR #358](https://github.com/theforeman/hammer-cli/pull/358)), [#34204](http://projects.theforeman.org/issues/34204)
12
+ * Add missing_args_error_result test helper ([PR #357](https://github.com/theforeman/hammer-cli/pull/357))
13
+ * Allow explicit strings in key=value options ([PR #356](https://github.com/theforeman/hammer-cli/pull/356)), [#34079](http://projects.theforeman.org/issues/34079)
14
+ * Bump to 3.2.0-develop
5
15
 
6
16
  ### 3.1.0 (2021-11-10)
7
17
  * 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 do |item|
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, '"\''), strip_chars(val.strip, '"\'')]
110
+ [strip_chars(key.strip, '"\''), val.strip]
113
111
  end.to_h
114
112
  else
115
- strip_chars(value.strip, '"\'')
113
+ value.strip
116
114
  end
117
115
  end
118
116
 
@@ -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
- system('stty', stty_save) # Restore
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
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new "3.1.1"
3
+ @version ||= Gem::Version.new "3.4.0"
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
@@ -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 "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'})
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 "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'})
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 "should deal with equal sign in value" do
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 "should parse arrays with spaces using by single quotes" do
201
- formatter.format("a=1,b=['1 1', ' 2 ', ' 3 3'],c=3").must_equal({'a' => '1', 'b' => ['1 1', ' 2 ', ' 3 3'], 'c' => '3'})
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 "should parse arrays with spaces using by double quotes" do
205
- formatter.format("a=1,b=[\"1 1\", \" 2 \", \" 3 3\"],c=3").must_equal({'a' => '1', 'b' => ['1 1', ' 2 ', ' 3 3'], 'c' => '3'})
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.1.1
4
+ version: 3.4.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: 2022-02-01 00:00:00.000000000 Z
12
+ date: 2022-08-09 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.2.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.2.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
@@ -174,8 +174,8 @@ extra_rdoc_files:
174
174
  - doc/output.md
175
175
  - doc/review_checklist.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