by William Morgan (masanjin.net/)
Main page: trollop.rubyforge.org
Release announcements and comments: all-thing.net/label/trollop
Documentation quickstart: See Trollop.options and then Trollop::Parser#opt. Also see the examples at trollop.rubyforge.org/.
Trollop 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, command subcompletion, and sensible defaults for everything you don’t specify.
require 'trollop'
opts = Trollop::options do
opt :monkey, "Use monkey mode" # flag --monkey, default false
opt :goat, "Use goat mode", :default => true # flag --goat, default true
opt :num_limbs, "Number of limbs", :default => 4 # integer --num-limbs <i>, default to 4
opt :num_thumbs, "Number of thumbs", :type => :int # integer --num-thumbs <i>, default nil
end
p opts # a hash: { :monkey => false, :goat => true, :num_limbs => 4, :num_thumbs => nil }
Copyright © 2008—2009 William Morgan. Trollop is distributed under the same terms as Ruby.
Generated with the Darkfish Rdoc Generator 1.1.6.