[ANN] Slop 1.5.0


Slop is a simple option parser with an easy to remember syntax and
friendly API.

Github: http://github.com/injekt/slop
Documentation: http://rubydoc.info/github/injekt/slop/master

Slop 1.5 introduces commands. Commands allow you to create nested Slop
objects. See an example here: https://gist.github.com/923386



gem install slop


git clone git://github.com/injekt/slop.git
gem build slop.gemspec
gem install slop-<version>.gem


# parse assumes ARGV, otherwise you can pass it your own Array
opts = Slop.parse do
  on :v, :verbose, 'Enable verbose mode'      # boolean value
  on :n, :name, 'Your name', true              # compulsory argument
  on :s, :sex, 'Your sex', :optional => false  # the same thing
  on :a, :age, 'Your age', :optional => true   # optional argument

# if ARGV is `-v --name 'lee jarvis' -s male`
opts.verbose? #=> true
opts.name?    #=> true
opts[:name]   #=> 'lee jarvis'
opts.age?     #=> false
opts[:age]    #=> nil

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs