Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3023 > unrolled thread

[ANN] Slop 1.5.0

Started byLee Jarvis <lee@jarvis.co>
First post2011-04-16 13:52 -0500
Last post2011-04-16 13:52 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.ruby


Contents

  [ANN] Slop 1.5.0 Lee Jarvis <lee@jarvis.co> - 2011-04-16 13:52 -0500

#3023 — [ANN] Slop 1.5.0

FromLee Jarvis <lee@jarvis.co>
Date2011-04-16 13:52 -0500
Subject[ANN] Slop 1.5.0
Message-ID<c8e5a17365f17223334c95510232efb1@ruby-forum.com>
Slop
====

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

Installation
------------

### Rubygems

    gem install slop

### GitHub

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

Usage
-----
    # 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
    end

    # 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

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web