Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created January 5, 2012 14:23
Show Gist options
  • Save leejarvis/1565456 to your computer and use it in GitHub Desktop.
Save leejarvis/1565456 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Slop version 3
require 'slop'
opts = Slop.new do
on :n, :name=, 'Your name', matches: /\A[a-zA-Z0-9]+\z/, required: true
on :p, :password, 'Your login password'
on :debug
on :verbose, unless: :debug?
on :A, :auth, if: proc { |o| o.name? && o.password? }
on :level, argument: :optional, default: 1, as: Integer
on :people, as: Array, limit: 3, delimiter: ':'
on :L, :limit, as: Range, default: 1..10
on :version do
print "Version 3.0"
exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment