lib/getopt/long.rb in getopt-1.3.2 vs lib/getopt/long.rb in getopt-1.3.3

- old
+ new

@@ -7,11 +7,11 @@ NEGATABLE = 4 class LongError < StandardError; end class Long - VERSION = "1.3.2" + VERSION = "1.3.3" # Takes an array of switches. Each array consists of three elements. def self.getopts(*switches) if switches.empty? raise ArgumentError, "no switches provided" @@ -30,16 +30,21 @@ # Set our list of valid switches, and proper types for each switch switches.each{ |switch| valid.push(switch[0]) # Set valid long switches - # Set type for long switch, default to BOOLEAN - switch[2] ||= BOOLEAN - types[switch[0]] = switch[2] - + # Set type for long switch, default to BOOLEAN. # Create synonym hash. Default to first char of long switch for # short switch, e.g. "--verbose" creates a "-v" synonym. - switch[1] ||= switch[0][1..2] + if switch[1].kind_of?(Fixnum) + switch[2] = switch[1] + types[switch[0]] = switch[2] + switch[1] = switch[0][1..2] + else + switch[2] ||= BOOLEAN + types[switch[0]] = switch[2] + switch[1] ||= switch[0][1..2] + end syns[switch[0]] = switch[1] syns[switch[1]] = switch[0] switch[1].each{ |char|