mixlib-cli 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mixlib/cli.rb +12 -1
- data/lib/mixlib/cli/version.rb +1 -1
- data/spec/mixlib/cli_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a5fa5c9380ff647b7d3fa3be1bff7e2103c9f94
|
4
|
+
data.tar.gz: d384bc4569b4577a90bc20d06d9d2f9b5564178d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea74cdb6f6afc9758a24a143c0d1702423e87a3fcce4749c61e3c83da4b289967a47a1473513b8f695a9d2e66d0aad188f1fdf1f6aae91648e4ce30f5c33b6ea
|
7
|
+
data.tar.gz: 62421ca5582e801d8e3112bbef7e55f16cdff8bf77c5520f7539bffa36e7602644ef2ac4aaee2733dda90db95156d58e06dfd2e7d0e1ddfae6856704b5c5b323
|
data/lib/mixlib/cli.rb
CHANGED
@@ -281,7 +281,18 @@ module Mixlib
|
|
281
281
|
|
282
282
|
parse_block =
|
283
283
|
Proc.new() do |c|
|
284
|
-
config[opt_key] =
|
284
|
+
config[opt_key] = if opt_val[:proc]
|
285
|
+
if opt_val[:proc].arity == 2
|
286
|
+
# New hotness to allow for reducer-style procs.
|
287
|
+
opt_val[:proc].call(c, config[opt_key])
|
288
|
+
else
|
289
|
+
# Older single-argument proc.
|
290
|
+
opt_val[:proc].call(c)
|
291
|
+
end
|
292
|
+
else
|
293
|
+
# No proc.
|
294
|
+
c
|
295
|
+
end
|
285
296
|
puts opts if opt_val[:show_options]
|
286
297
|
exit opt_val[:exit] if opt_val[:exit]
|
287
298
|
end
|
data/lib/mixlib/cli/version.rb
CHANGED
data/spec/mixlib/cli_spec.rb
CHANGED
@@ -149,6 +149,16 @@ describe Mixlib::CLI do
|
|
149
149
|
@cli.config[:number].should == 4
|
150
150
|
end
|
151
151
|
|
152
|
+
it "should pass the existing value to two-argument procs" do
|
153
|
+
TestCLI.option(:number,
|
154
|
+
:short => "-n NUMBER",
|
155
|
+
:proc => Proc.new { |value, existing| existing ||= []; existing << value; existing }
|
156
|
+
)
|
157
|
+
@cli = TestCLI.new
|
158
|
+
@cli.parse_options([ "-n", "2", "-n", "3" ])
|
159
|
+
@cli.config[:number].should == %w{2 3}
|
160
|
+
end
|
161
|
+
|
152
162
|
it "should set the corresponding config value to true for boolean arguments" do
|
153
163
|
TestCLI.option(:i_am_boolean, :short => "-i", :boolean => true)
|
154
164
|
@cli = TestCLI.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlib-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|