Sha256: 2f7c4c4db42ef512f8c580ea73c0cf050b3cf7654edd02a8248ef25128d71848
Contents?: true
Size: 782 Bytes
Versions: 12
Compression:
Stored size: 782 Bytes
Contents
module SOPT def self.consume(args = ARGV) i = 0 values = {} while i < args.length do current = args[i] if m = current.match(/--?(.+?)(?:=(.+))?$/) key = $1 value = $2 input = inputs.include?(key)? key : shortcuts[key] if input.nil? i += 1 next else args.delete_at i end else i += 1 next end if input_types[input] == :string value = args.delete_at(i) if value.nil? values[input] = value else values[input] = %w(F false FALSE no).include?(value)? false : true end end IndiferentHash.setup values values end def self.get(opt_str) SOPT.parse(opt_str) SOPT.consume(ARGV) end end
Version data entries
12 entries across 12 versions & 1 rubygems