require 'optiflag' # Example 1.1: # Variation 1: add a method 'handle_errors_and_help' to autoparse, check, and augment ARGV module Example extend OptiFlag::Flagset flag "dir" flag "log" flag "username" flag "password" handle_errors_and_help end # Some code to _use_ the values puts "User has input:#{ ARGV.flag_value.dir } for dir" puts "User has input:#{ ARGV.flag_value.log } for log" puts "User has input:#{ ARGV.flag_value.username } for username" puts "User has input:#{ ARGV.flag_value.password } for password" puts " The variable ARGV has been extend to hold the return variables." # Try the following inputs ## Breaks: #h# ruby example_1_1.rb ## Works: #h# ruby example_1_1.rb -log logdirectory -dir directory -username me -password fluffy # ruby example_1_1.rb --log logdirectory --dir directory --username me --password fluffy