diff options
| author | Max Howell | 2012-03-06 20:11:35 +0000 |
|---|---|---|
| committer | Max Howell | 2012-03-06 20:28:06 +0000 |
| commit | 03b2aae0a8aa89fa350db2aa8dcb3ac4b7e69bff (patch) | |
| tree | 7d3fb9711ea35579113b174ad1e8a063e1d30f1a /Library/Homebrew/extend | |
| parent | 4e8afeb839a912b83f43e19388c6b53389992436 (diff) | |
| download | homebrew-03b2aae0a8aa89fa350db2aa8dcb3ac4b7e69bff.tar.bz2 | |
Proper single character switch handling
Includes a test. So now you can do `brew cleanup -ns` and it will work.
Diffstat (limited to 'Library/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/ARGV.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 24d70cb1f..130058327 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -103,6 +103,16 @@ module HomebrewArgvExtension return false end + # eg. `foo -ns -i --bar` has three switches, n, s and i + def switch? switch_character + return false if switch_character.length > 1 + options_only.each do |arg| + next if arg[1..1] == '-' + return true if arg.include? switch_character + end + return false + end + def usage require 'cmd/help' Homebrew.help_s |
