gem – trollop

trollop lets you easily create script parameters with meaningful names, instead of useing ARGV[0], ARGV[1],...etc.

If you have the following in your ruby script:

cat ./testscript.rb
#!/usr/bin/env ruby

require 'trollop'

opts = Trollop::options do
  opt :hostname, "Server FQDN.", :type => :string

puts opts[:hostname]

Next we install the gem:

$ gem install trollop

Now we have builtin "help" feature:

$ ruby ./testscript.rb --help
  -h, --hostname=    Server FQDN.
  -e, --help            Show this message

Now if we do:

$ ruby ./testscript.rb