Skip to content

Instantly share code, notes, and snippets.

@auxesis
Last active December 14, 2015 19:49
Show Gist options
  • Select an option

  • Save auxesis/5139413 to your computer and use it in GitHub Desktop.

Select an option

Save auxesis/5139413 to your computer and use it in GitHub Desktop.
# For easier parsing of command line arguments in cap
def get_argument(parameter, opts={})
default = opts[:default] || false
result = ENV[parameter.downcase] || ENV[parameter.upcase] or return default
trues, falses = %w(y yes t true), %w(n no f false)
if (trues + falses).include?(result.downcase)
result = false if falses.include?(result.downcase)
result = true if trues.include?(result.downcase)
else
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment