require 'optiflag' # Example 1: Four required flags module Example extend OptiFlag::Flagset flag "dir" flag "log" flag "username" flag "password" end result = Example::parse(ARGV) if result.errors? result.errors.divulge_problems exit end # Some code to _use_ the values puts "User has input:#{ result.flag_value.dir } for dir" puts "User has input:#{ result.flag_value.log } for log" puts "User has input:#{ result.flag_value.username } for username" puts "User has input:#{ result.flag_value.password } for password" puts "The variable 'result' is actually just a copy of ARGV" puts "that has been extend to hold the return variables:" puts "See: #{ result.join(', ') }" # Try the following inputs # ruby example_1.rb #h# ruby example_1.rb -log logdirectory -dir directory -username me -password fluffy