mixlib-cli 2.1.1 → 2.1.5
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 +28 -25
- data/lib/mixlib/cli/formatter.rb +1 -0
- data/lib/mixlib/cli/version.rb +1 -1
- 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: 846ac98eeac7702d578383b5d8820e39f8cea5c23c6e4b137f2db0199becdefe
|
4
|
+
data.tar.gz: 772268d27fa8f9e17bcf4c59ce03e656b58b2a4e5e16ffc43c284424b365b1fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f838cb43f024b39db6bd9975802fb75d2707524c2d2c34ce7f895c2b218e22d0d3a7f62f95c40ea5feddcede09c6a7e57656966d8b4f8d92f265ead741d0b757
|
7
|
+
data.tar.gz: aa62d3c7c57e47d7bb7aea504da13f3ded85402a2783ee4c7635a8ac32658cc4f5655384a6d53d6cf03fb78013d27d713255f9317336ff65ac9ef892f29525ec
|
data/lib/mixlib/cli.rb
CHANGED
@@ -52,8 +52,8 @@ module Mixlib
|
|
52
52
|
# contents will be iterated and cloned as well.
|
53
53
|
def deep_dup(object)
|
54
54
|
cloned_object = object.respond_to?(:dup) ? object.dup : object
|
55
|
-
if cloned_object.
|
56
|
-
if cloned_object.
|
55
|
+
if cloned_object.is_a?(Enumerable)
|
56
|
+
if cloned_object.is_a?(Hash)
|
57
57
|
new_hash = cloned_object.class.new
|
58
58
|
cloned_object.each do |key, value|
|
59
59
|
cloned_key = deep_dup(key)
|
@@ -122,7 +122,8 @@ module Mixlib
|
|
122
122
|
# i
|
123
123
|
def option(name, args)
|
124
124
|
@options ||= {}
|
125
|
-
raise(ArgumentError, "Option name must be a symbol") unless name.
|
125
|
+
raise(ArgumentError, "Option name must be a symbol") unless name.is_a?(Symbol)
|
126
|
+
|
126
127
|
@options[name.to_sym] = args
|
127
128
|
end
|
128
129
|
|
@@ -148,12 +149,12 @@ module Mixlib
|
|
148
149
|
# === Returns
|
149
150
|
# <Hash> :: The config hash for the created option.
|
150
151
|
def deprecated_option(name,
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
152
|
+
replacement: nil,
|
153
|
+
long: nil,
|
154
|
+
short: nil,
|
155
|
+
boolean: false,
|
156
|
+
value_mapper: nil,
|
157
|
+
keep: true)
|
157
158
|
|
158
159
|
description = if replacement
|
159
160
|
replacement_cfg = options[replacement]
|
@@ -165,15 +166,15 @@ module Mixlib
|
|
165
166
|
value_mapper ||= Proc.new { |v| v }
|
166
167
|
|
167
168
|
option(name,
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
169
|
+
long: long,
|
170
|
+
short: short,
|
171
|
+
boolean: boolean,
|
172
|
+
description: description,
|
173
|
+
on: :tail,
|
174
|
+
deprecated: true,
|
175
|
+
keep: keep,
|
176
|
+
replacement: replacement,
|
177
|
+
value_mapper: value_mapper)
|
177
178
|
end
|
178
179
|
|
179
180
|
# Get the hash of current options.
|
@@ -193,7 +194,8 @@ module Mixlib
|
|
193
194
|
# === Returns
|
194
195
|
# @options<Hash>:: The current options hash.
|
195
196
|
def options=(val)
|
196
|
-
raise(ArgumentError, "Options must recieve a hash") unless val.
|
197
|
+
raise(ArgumentError, "Options must recieve a hash") unless val.is_a?(Hash)
|
198
|
+
|
197
199
|
@options = val
|
198
200
|
end
|
199
201
|
|
@@ -256,9 +258,9 @@ module Mixlib
|
|
256
258
|
# === Returns
|
257
259
|
# object<Mixlib::Config>:: Returns an instance of whatever you wanted :)
|
258
260
|
def initialize(*args)
|
259
|
-
@options =
|
260
|
-
@config =
|
261
|
-
@default_config =
|
261
|
+
@options = {}
|
262
|
+
@config = {}
|
263
|
+
@default_config = {}
|
262
264
|
@opt_parser = nil
|
263
265
|
|
264
266
|
# Set the banner
|
@@ -316,9 +318,10 @@ module Mixlib
|
|
316
318
|
exit 2
|
317
319
|
end
|
318
320
|
if opt_config[:in]
|
319
|
-
unless opt_config[:in].
|
321
|
+
unless opt_config[:in].is_a?(Array)
|
320
322
|
raise(ArgumentError, "Options config key :in must receive an Array")
|
321
323
|
end
|
324
|
+
|
322
325
|
if config[opt_key] && !opt_config[:in].include?(config[opt_key])
|
323
326
|
reqarg = Formatter.combined_option_display_name(opt_config[:short], opt_config[:long])
|
324
327
|
puts "#{reqarg}: #{config[opt_key]} is not one of the allowed values: #{Formatter.friendly_opt_list(opt_config[:in])}"
|
@@ -358,7 +361,7 @@ module Mixlib
|
|
358
361
|
end
|
359
362
|
|
360
363
|
parse_block =
|
361
|
-
Proc.new
|
364
|
+
Proc.new do |c|
|
362
365
|
config[opt_key] = if opt_val[:proc]
|
363
366
|
if opt_val[:proc].arity == 2
|
364
367
|
# New hotness to allow for reducer-style procs.
|
@@ -427,7 +430,7 @@ module Mixlib
|
|
427
430
|
end
|
428
431
|
|
429
432
|
def build_option_arguments(opt_setting)
|
430
|
-
arguments =
|
433
|
+
arguments = []
|
431
434
|
|
432
435
|
arguments << opt_setting[:short] if opt_setting[:short]
|
433
436
|
arguments << opt_setting[:long] if opt_setting[:long]
|
data/lib/mixlib/cli/formatter.rb
CHANGED
data/lib/mixlib/cli/version.rb
CHANGED
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: 2.1.
|
4
|
+
version: 2.1.5
|
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: 2019-
|
11
|
+
date: 2019-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple mixin for CLI interfaces, including option parsing
|
14
14
|
email: info@chef.io
|