Last active
December 14, 2015 19:49
-
-
Save auxesis/5139413 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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