From: Panagiotis Atmatzidis Date: 2012-07-25T04:18:56+09:00 Subject: simple optparse question on available options Hello, I'm using optparse for a cli script. I need an argument (-s, --sort) to accept only 3 possible options :date, :country, :ipfreq, so here is my piece of optparse code: [...] # http://ruby.about.com/od/advancedruby/a/optionparser2.htm options[:sort] = :yes # <--- Not sure what this does, probably sets a default value to :sort ... I just grab the code sample from the link above opts.on('-s', '--sort OPT', [:date, :country, :ip], 'Sorts by [date, country, ip-frequency]') do |sort| options[:sort] = sort end [...] Now I don't understand how to use this code in my exec function: [...] if File.exists?($logfile) $f2b = F2bread.new($logfile) if options[:info] $f2b.info # opts.on('-s', '--sort OPT', [:date, :country, :ip], 'Sorts by [date, country, ip-frequency]') do |sort| elsif options[:sort] if options[:sort] == 'date' $f2b.sort_by_date elsif options[:sort] == "country" # <--- something like this? # etc... [...] Any sort of hints are always welcome. Best regards, Panagiotis Atmatzidis ----------------------------- Pharmacy Student at VFU email4lists: ml@convalesco.org More info: http://about.me/atmosx The wise man said: "Never argue with an idiot, he brings you down to his level and beat you with experience."