[ANN] Slop 1.5.0

L

Lee Jarvis

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', :eek:ptional => false # the same thing
on :a, :age, 'Your age', :eek:ptional => 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] Slop 1.3.0 0
[ANN] map-1.5.0 3
[ANN] Mail 1.5.0 0
[ANN] sys-admin 1.5.0 0
ANN: Sequel 1.5.0 Released 0
[ANN] Cinch 1.1.2 released 0
[ANN] Cinch 1.1.0 released 0
[ANN]"specific_install" gem plugin released 0

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top