lib/eco/cli/scripting/args_helpers.rb in eco-helpers-3.0.14 vs lib/eco/cli/scripting/args_helpers.rb in eco-helpers-3.0.15
- old
+ new
@@ -76,18 +76,27 @@
k_1 < k_2
end
# @return [String, Boolean] the argument value if `with_param` or a `Boolean` if not.
def get_arg(key, with_param: false, valid: true)
- # track what a known option looks like
- known_argument(key, with_param: with_param)
- return nil unless (index = get_arg_index(key))
- return true unless with_param
+ case key
+ when Array
+ key.reduce(nil) do |value, k|
+ next value unless value.nil?
- value = argv[index + 1]
- #puts "modifier argument: #{value}"
- value = nil if valid && is_modifier?(value)
- value
+ get_arg(k, with_param: with_param, valid: valid)
+ end
+ else
+ # track what a known option looks like
+ known_argument(key, with_param: with_param)
+ return nil unless (index = get_arg_index(key))
+ return true unless with_param
+
+ value = argv[index + 1]
+ #puts "modifier argument: #{value}"
+ value = nil if valid && is_modifier?(value)
+ value
+ end
end
# @return [String] the filename.
def get_file(key, required: false, should_exist: true)
filename = get_arg(key, with_param: true)