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