Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created January 12, 2012 14:48
Show Gist options
  • Save leejarvis/1600937 to your computer and use it in GitHub Desktop.
Save leejarvis/1600937 to your computer and use it in GitHub Desktop.
# Slop version 3
require 'slop'
opts = Slop.optspec(<<-SPEC)
n,name= Your name
p,pass=? An optional password
A,auth Use authentication (requires password)
SPEC
opts.parse %w[ --name Lee -p 1c03 ]
p opts.fetch_option(:pass).accepts_optional_argument? #=> true
p opts.to_hash #=> {:name=>"Lee", :pass=>"1c03", :auth=>nil}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment