Skip to content

Instantly share code, notes, and snippets.

@rickhull
Created August 7, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickhull/4bcbc7debbcaf7e635ff to your computer and use it in GitHub Desktop.
Save rickhull/4bcbc7debbcaf7e635ff to your computer and use it in GitHub Desktop.
usage proc for opts n stuff
require 'slop'
opts = Slop.parse do |o|
# ...
end
def opts.usage(msg = nil)
puts self
puts msg if msg
exit 1
end
opts.usage("go home you're drunk")
require 'slop'
opts = Slop.parse do |o|
# ...
end
usage = proc do |msg|
puts opts
puts msg if msg
exit 1
end
usage["go home you're drunk"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment