From b63ec18564017534822d749e7e712cd0d45b8ef6 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 6 Mar 2012 20:11:35 +0000 Subject: Proper single character switch handling Includes a test. So now you can do `brew cleanup -ns` and it will work. --- Library/Homebrew/extend/ARGV.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Library/Homebrew/extend') 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 -- cgit v1.2.3