Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
Created April 29, 2012 23:03
Show Gist options
  • Select an option

  • Save RyanScottLewis/2553765 to your computer and use it in GitHub Desktop.

Select an option

Save RyanScottLewis/2553765 to your computer and use it in GitHub Desktop.
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ gem list slop
*** LOCAL GEMS ***
slop (3.1.1)
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ cat test.rb
require 'slop'
opts = Slop.new do
on :v, :verbose, "Enable verbose mode"
end
opts.parse
p opts.to_hash
print "Verbose? "
puts opts.verbose?, ""
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ ruby test.rb
{:verbose=>nil}
Verbose? false
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ ruby test.rb -v
{:verbose=>nil}
Verbose? true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment