--help and --version only apply as first argument
This fixes external commands that provide their own help and version subcommands. Closes Homebrew/homebrew#26755.
This commit is contained in:
parent
f446e95852
commit
2c61e3c02a
@ -149,14 +149,6 @@ 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
|
||||
|
||||
@ -15,11 +15,12 @@ HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.dirname.parent.join("Lib
|
||||
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
|
||||
require 'global'
|
||||
|
||||
if ARGV.help?
|
||||
if ARGV.empty? || ARGV[0] =~ /(-h$|--help$|--usage$|-\?$|help$)/
|
||||
# TODO - `brew help cmd` should display subcommand help
|
||||
require 'cmd/help'
|
||||
puts ARGV.usage
|
||||
exit ARGV.any? ? 0 : 1
|
||||
elsif ARGV.version?
|
||||
elsif ARGV.first == '--version'
|
||||
puts HOMEBREW_VERSION
|
||||
exit 0
|
||||
elsif ARGV.first == '-v'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user