require 'optiflag' # Example 7: Character Flags module HashAcess extend OptiFlag::Flagset character_flag :l, :list_group character_flag :s, :list_group character_flag :a, :list_group character_flag :x do description "Extract" end character_flag :v do description "Verbose" end character_flag :f do description "Archive File" end handle_errors_and_help end f = ARGV.flag_value puts "'l' flag set?: #{ f.l? }" puts "'s' flag set?: #{ f.s? }" puts "'a' flag set?: #{ f.a? }" puts "'x' flag set?: #{ f.x? }" puts "'f' flag set?: #{ f.f? }" puts "'v' flag set?: #{ f.v? }" #h# ruby example_7.rb -lsa #h# ruby example_7.rb -ls -a #h# ruby example_7.rb -a -s -l #h# ruby example_7.rb -als -x -vf #h# ruby example_7.rb -s -xvf #h# ruby example_7.rb -lsaxvf