Sha256: 32f936ecc1891b6ece8a65382120cb4d4cbacb0428dc91df918ba8f615eecc7a
Contents?: true
Size: 823 Bytes
Versions: 6
Compression:
Stored size: 823 Bytes
Contents
#################################################### # example_std.rb # # Some samples of how to use the Getopt::Std class. ##################################################### require "getopt/std" include Getopt # Try passing different switches to this script to see what happens opts = Std.getopts("o:ID") p opts # User passes "-o hello -I" # Result: {"o" => "hello", "I" => true} # User passes "-I -D" # Result: {"I" => true, "D" => true} # User passes nothing # Result: {} # User passes "-o hello -o world -I" # Result: {"I" => true, "o" => ["hello", "world"]} # User passes "-o -I" # Result: Getopt::StdError, because -o requires an argument (and does not # accept -I as an argument, since it is a valid switch) # User passes "-I -X" # Result: Getopt::StdError, because -X was not listed as a valid switch.
Version data entries
6 entries across 6 versions & 1 rubygems