require 'optiflag' # Example 2.6: # Variation 6: Using the optional switch flag, a zero argument optional flag module Example extend OptiFlag::Flagset flag "dir" optional_switch_flag "clear" handle_errors_and_help end flag = ARGV.flag_value if flag.clear? puts "The optional switch flag -clear has been invoked" else puts "The optional switch flag -clear was NOT invoked" end #h# ruby example_2_6.rb -dir c:/dir #h# ruby example_2_6.rb -clear -dir c:/dir