http://manageiq.github.io/optimist/
Optimist.options
and then Optimist::Parser#opt
.Optimist is a commandline option parser for Ruby that just gets out of your way. One line of code per option is all you need to write. For that, you get a nice automatically-generated help page, robust option parsing, and sensible defaults for everything you don't specify.
require 'optimist'
opts = Optimist::options do
opt :monkey, "Use monkey mode" # flag --monkey, default false
opt :name, "Monkey name", :type => :string # string --name <s>, default nil
opt :num_limbs, "Number of limbs", :default => 4 # integer --num-limbs <i>, default to 4
end
p opts # a hash: { :monkey=>false, :name=>nil, :num_limbs=>4, :help=>false }
Copyright © 2008-2014 William Morgan.
Copyright © 2014 Red Hat, Inc.
Optimist is released under the MIT License.