Return to Snippet

Revision: 6399
at May 20, 2008 03:35 by mikegreen


Initial Code
require 'optparse'

app = Hash.new

options = OptionParser.new do |opts|
  opts.on("-o", "--option [ARG]", "Option description") do |opt|
    app['option'] = opt
  end
end

begin
  options.parse!(ARGV)
rescue OptionParser::ParseError => e
  puts e
end

Initial URL


Initial Description
Simple command line option parser snippet

Initial Title
Ruby Command Line Option Parser

Initial Tags
ruby

Initial Language
Ruby