aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ARGV.rb8
-rwxr-xr-xLibrary/brew.rb10
2 files changed, 13 insertions, 5 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index c2e1a9c2e..55f6b356a 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -157,6 +157,14 @@ module HomebrewArgvExtension
include? '--force-bottle'
end
+ def help?
+ empty? || grep(/(-h|--help|--usage|-\?|help)/).any?
+ end
+
+ def version?
+ include? '--version'
+ end
+
# eg. `foo -ns -i --bar` has three switches, n, s and i
def switch? switch_character
return false if switch_character.length > 1
diff --git a/Library/brew.rb b/Library/brew.rb
index 455f30464..27d66d20f 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -16,14 +16,14 @@ $:.unshift(HOMEBREW_LIBRARY_PATH + '/vendor')
$:.unshift(HOMEBREW_LIBRARY_PATH)
require 'global'
-case ARGV.first when '-h', '--help', '--usage', '-?', 'help', nil
+if ARGV.help?
require 'cmd/help'
- puts Homebrew.help_s
- exit ARGV.first ? 0 : 1
-when '--version'
+ puts ARGV.usage
+ exit ARGV.any? ? 0 : 1
+elsif ARGV.version?
puts HOMEBREW_VERSION
exit 0
-when '-v'
+elsif ARGV.first == '-v'
puts "Homebrew #{HOMEBREW_VERSION}"
# Shift the -v to the end of the parameter list
ARGV << ARGV.shift