nub 0.0.40 → 0.0.41
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/lib/nub/commander.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 252475d41897431fae67e7f7c9b613db0ce9fc59c7bbf83dd67cec52b5f9611b
|
4
|
+
data.tar.gz: 382e539ad717e3a0830f4070112085ff568ebb1db18e32b3f06f0eeaa3165439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22f5da62845e4cd9a2aac1dc726c6c5c30ee854dd20999b177ad9db412bd7343bafc09de0ccf309fbf1548a75d557a68a39510be3de030e479db080ec53ffbee
|
7
|
+
data.tar.gz: 668f01238e0e8501965b45b5ea1beac2fbac9981e0dbae79233ca43af08036d39b8f4832d413de499890334adae07695e2da9eb1f8c818bb119cade426b82ad7
|
data/lib/nub/commander.rb
CHANGED
@@ -242,22 +242,22 @@ class Commander
|
|
242
242
|
sym = "#{cmd.name}#{pos}".to_sym
|
243
243
|
end
|
244
244
|
|
245
|
-
# Convert value to appropriate type
|
245
|
+
# Convert value to appropriate type and validate against allowed
|
246
246
|
# --------------------------------------------------------------------
|
247
247
|
if value
|
248
|
-
if cmd_opt.type ==
|
248
|
+
if cmd_opt.type == String
|
249
|
+
if cmd_opt.allowed.any?
|
250
|
+
!puts("Error: invalid string value '#{value}'".colorize(:red)) && !puts(cmd.help) and
|
251
|
+
exit if !cmd_opt.allowed.include?(value)
|
252
|
+
end
|
253
|
+
elsif cmd_opt.type == Integer
|
249
254
|
value = value.to_i
|
250
|
-
|
251
|
-
# Validate allowed values
|
252
255
|
if cmd_opt.allowed.any?
|
253
256
|
!puts("Error: invalid integer value '#{value}'".colorize(:red)) && !puts(cmd.help) and
|
254
257
|
exit if !cmd_opt.allowed.include?(value)
|
255
258
|
end
|
256
|
-
|
257
259
|
elsif cmd_opt.type == Array
|
258
260
|
value = value.split(',')
|
259
|
-
|
260
|
-
# Validate allowed values
|
261
261
|
if cmd_opt.allowed.any?
|
262
262
|
value.each{|x|
|
263
263
|
!puts("Error: invalid array value '#{x}'".colorize(:red)) && !puts(cmd.help) and
|