From: dusty Date: 2008-07-03T12:03:37+09:00 Subject: Re: Lost with OptionParser Here is a quick example program. Hope this gets you started. #!/usr/bin/env ruby require 'optparse' options = {} opts = OptionParser.new opts.on("-W", "--weekday", "Print out the weekday") do |v| options[:weekday] = true end opts.on("-H", "--hour TYPE", "Print out the hour in 24 or 12 hour clock") do |v| options[:hour] = v end opts.parse! unless options[:weekday] || options[:hour] puts opts exit end if options[:weekday] puts Time.now.strftime("%A") exit end case options[:hour] when "12" puts Time.now.strftime("%I") when "24" puts Time.now.strftime("%H") else puts "You must send 12 or 24 as an argument to --hour" end