Skip to content

Commit

Permalink
brew.rb: update help parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vladshablinsky committed Oct 1, 2016
1 parent fd01497 commit d92a1ad
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Library/Homebrew/brew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ def require?(path)

empty_argv = ARGV.empty?
help_flag_list = %w[-h --help --usage -?]
help_flag = false
help_flag = !ENV["HOMEBREW_HELP"].nil?
internal_cmd = true
cmd = nil

ARGV.dup.each_with_index do |arg, i|
break if help_flag && cmd

if help_flag_list.include?(arg)
# Option-style help: Both `--help <cmd>` and `<cmd> --help` are fine.
help_flag = true
elsif arg == "help" && !cmd
if arg == "help" && !cmd
# Command-style help: `help <cmd>` is fine, but `<cmd> help` is not.
help_flag = true
elsif !cmd
elsif !cmd && !help_flag_list.include?(arg)
cmd = ARGV.delete_at(i)
end
end
Expand Down

0 comments on commit d92a1ad

Please sign in to comment.