lib/getopt/std.rb in getopt-1.3.5 vs lib/getopt/std.rb in getopt-1.3.6

- old
+ new

@@ -1,10 +1,11 @@ module Getopt - class StdError < StandardError; end class Std - VERSION = "1.3.4" + class Error < StandardError; end + VERSION = '1.3.6' + # Processes single character command line options with option # clustering. This information is parsed from ARGV and returned # as a hash, with the switch (minus the "-") as the key. The value # for that key is either true/false (boolean switches) or the argument # that was passed to the switch. @@ -22,29 +23,29 @@ first, rest = $1, $2 pos = switches.index(first) # Switches on the command line must appear among the characters # declared in +switches+. - raise StdError, "invalid option '#{first}'" unless pos + raise Error, "invalid option '#{first}'" unless pos if args[pos+1] == ":" ARGV.shift if rest.empty? rest = ARGV.shift # Ensure that switches requiring arguments actually # receive a (non-switch) argument. if rest.nil? || rest.empty? - raise StdError, "missing argument for '-#{args[pos]}'" + raise Error, "missing argument for '-#{args[pos]}'" end # Do not permit switches that require arguments to be # followed immediately by another switch. if args.include?(rest) || args.include?(rest[1..-1]) err = "cannot use switch '#{rest}' as argument " err += "to another switch" - raise StdError, err + raise Error, err end # For non boolean switches, arguments that appear multiple # times are converted to an array (or pushed onto an already # existant array). @@ -57,10 +58,10 @@ # Do not permit switches that require arguments to be # followed immediately by another switch. if args.include?(rest) || args.include?(rest[1..-1]) err = "cannot use switch '#{rest}' as argument " err += "to another switch" - raise StdError, err + raise Error, err end end else hash[first] = true # Boolean switch if rest.empty?