diff options
| author | Jack Nagel | 2013-05-20 22:34:54 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-05-20 22:34:54 -0500 |
| commit | c9ce32d0f1ac550a25153b376c6584e5d7004a85 (patch) | |
| tree | 30028512f13dffc19c0be8005d2de2f325c72d81 /Library | |
| parent | 863d2b253a4c4be255e309b18d4fd14ad94155c1 (diff) | |
| download | brew-c9ce32d0f1ac550a25153b376c6584e5d7004a85.tar.bz2 | |
Simplify implementation of ARGV.flag? and .switch?
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/ARGV.rb | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 32acee7da..b71d5f103 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -135,22 +135,17 @@ module HomebrewArgvExtension end def flag? flag - options_only.each do |arg| - return true if arg == flag - next if arg[1..1] == '-' - return true if arg.include? flag[2..2] + options_only.any? do |arg| + arg == flag || arg[1..1] != '-' && arg.include?(flag[2..2]) end - 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 + options_only.any? do |arg| + arg[1..1] != '-' && arg.include?(switch_character) end - return false end def usage |
