examples/example_long.rb in getopt-1.4.1 vs examples/example_long.rb in getopt-1.4.2
- old
+ new
@@ -3,15 +3,16 @@
#
# A series of examples to demonstrate the different ways that you can
# handle command line options.
##########################################################################
require "getopt/long"
+include Getopt
# The truly lazy way. This creates two valid command line switches,
# automatically creates single letter switches (-f, -b), and sets each
# switch type to BOOLEAN.
-opts = Getopt::Long.getopts("--foo --bar")
+#opts = Getopt::Long.getopts("--foo --bar")
# Here's a comprehensive example that uses all types and options.
opts = Getopt::Long.getopts(
["--foo"], # --foo, -f, BOOLEAN
["--bar", "-z"], # --bar, -z, BOOLEAN
@@ -19,9 +20,11 @@
["--name", "-n", REQUIRED], # --name, -n, REQUIRED
["--more", "-m", INCREMENT], # --more, -m, INCREMENT
["--verbose", "-v", BOOLEAN], # --verbose, -v, BOOLEAN
["--my-name", "-x", REQUIRED] # --my-name, -x, REQUIRED
)
+
+p opts
# Using the above example:
# User passes "-f"
# opts -> { "f" => true, "foo" => true }