lib/eco/cli/scripting/args_helpers.rb in eco-helpers-3.0.7 vs lib/eco/cli/scripting/args_helpers.rb in eco-helpers-3.0.8

- old
+ new

@@ -1,9 +1,11 @@ module Eco class CLI class Scripting module ArgsHelpers + class UnknownArgument < ArgumentError; end + # @return [Array<String] the command line arguments. def argv @argv || ARGV end @@ -29,11 +31,12 @@ exclude: exclude, all_available: all_available } unknown = arguments.unknown(**args) do |key, correct| next suggestions[key] = correct unless correct.empty? - suggstions[key] = '-- not known similar options! --' + + suggestions[key] = ['-- not known similar options! --'] end unknown = unknown.select {|arg| is_modifier?(arg)} if only_options return if unknown.empty? @@ -47,10 +50,10 @@ msg = "\nThere are UNKNOWN OPTIONS in your command line arguments !!" msg << "\n * #{suggestions_str}\n" msg << "\nUse 'ruby main.rb -org [-usecase] --help -options' for more information" msg << "\n - Please, remember that use case specific options " msg << "should come after the use case in the command line.\n" - raise msg + raise UnknownArgument, msg end # @return [Boolean] if `key` is in the command line. def arg?(key) argv.include?(key)