Created
August 7, 2015 20:48
-
-
Save rickhull/4bcbc7debbcaf7e635ff to your computer and use it in GitHub Desktop.
usage proc for opts n stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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