lib/eco/cli/scripting/args_helpers.rb in eco-helpers-0.9.2 vs lib/eco/cli/scripting/args_helpers.rb in eco-helpers-0.9.3
- old
+ new
@@ -2,19 +2,25 @@
class CLI
class Scripting
module ArgsHelpers
def is_modifier?(value)
- value&.start_with?("-")
+ Argument.is_modifier?(value)
end
def arguments
@arguments ||= Arguments.new
end
- def stop_on_unknown!(exclude: [])
- if arguments.any_unkown?(exclude: exclude)
- raise "There are unknown options in your command line arguments: #{arguments.unknown(exclude: exclude)}"
+ def stop_on_unknown!(exclude: [], only_options: false)
+ # validate only those that are options
+ unknown = arguments.unknown(exclude: exclude)
+ if only_options
+ unknown = unknown..select {|arg| is_modifier?(arg)}
+ end
+
+ unless unknown.empty?
+ raise "There are unknown options in your command line arguments: #{unknown}"
end
end
def get_arg(key, with_param: false, valid: true)
# track what a known option looks like