


In this example, we create the parser without using Optimist::options, and force it to display the help message (and exit) if the user doesn't supply any arguments. To understand, read the examples below, theĮxamples Simple require ' optimist ' opts = Optimist :: options do opt :monkey, " Use monkey mode " # flag -monkey, default false opt :name, " Monkey name ", :type => :string # string -name, default nil opt :num_limbs, " Number of limbs ", :default => 4 # integer -num-limbs, default to 4 end p opts # a hash: " Specialized parsing behaviorĭoes too much for us. To hack on it, command your computer to git clone git:///manageiq/optimist.git, or see the You can use rubygems and command your computer to.Optimist is a single file with no dependencies.Support for long options, short options, subcommands, and automatic type validation and conversion.Īutomatic help message generation, wrapped to current screen width. No tweaking necessary, much tweaking possible. Throw it in lib/ if you don't want to make it a Rubygem dependency. For that, you get a nice automatically-generated help page, robust option parsing, and sensible defaults for everything you don't specify. One line of code per option is all you need to write.

Optimist is a commandline option parser for Ruby that just gets out of your way.
