/ Published in: Ruby
                    
                                        
Simple command line option parser snippet
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
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
Comments
 Subscribe to comments
                    Subscribe to comments
                
                