internally convert nargs to a range if it was a Fixnum for processing
This commit is contained in:
parent
21d64600dc
commit
ef860a8eee
10
lib/yawpa.rb
10
lib/yawpa.rb
@ -36,21 +36,21 @@ module Yawpa
|
|||||||
nargs = opt_config[:nargs] || 0
|
nargs = opt_config[:nargs] || 0
|
||||||
if nargs == 0
|
if nargs == 0
|
||||||
opts[param_key] = true
|
opts[param_key] = true
|
||||||
elsif nargs.class == Fixnum
|
else
|
||||||
|
nargs = (nargs..nargs) if nargs.class == Fixnum
|
||||||
opts[param_key] = []
|
opts[param_key] = []
|
||||||
opts[param_key] << val if val
|
opts[param_key] << val if val
|
||||||
if opts[param_key].length < nargs
|
if opts[param_key].length < nargs.last
|
||||||
gathered = _gather(i + 1, nargs - opts[param_key].length, params)
|
gathered = _gather(i + 1, nargs.last - opts[param_key].length, params)
|
||||||
i += gathered.length
|
i += gathered.length
|
||||||
opts[param_key] += gathered
|
opts[param_key] += gathered
|
||||||
if opts[param_key].length < nargs
|
if opts[param_key].length < nargs.first
|
||||||
raise InvalidArgumentsException.new("Not enough arguments supplied for option '#{param_name}'")
|
raise InvalidArgumentsException.new("Not enough arguments supplied for option '#{param_name}'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if opts[param_key].length == 1
|
if opts[param_key].length == 1
|
||||||
opts[param_key] = opts[param_key].first
|
opts[param_key] = opts[param_key].first
|
||||||
end
|
end
|
||||||
elsif nargs.class == Range
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user