Fixes help querying

- If a non-existent command with a flag is queried to Cask, the latter
is printed instead of the command
 - If the help from a not-yet-tapped cask's command is queried, it
prints brew tap's help infinitely

Fixes caskroom/homebrew-cask#28977
This commit is contained in:
L. E. Segovia 2017-10-12 00:11:11 -03:00
parent 91ab116ace
commit d1262868a9
2 changed files with 5 additions and 2 deletions

View File

@ -32,7 +32,7 @@ begin
empty_argv = ARGV.empty? empty_argv = ARGV.empty?
help_flag_list = %w[-h --help --usage -?] help_flag_list = %w[-h --help --usage -?]
help_flag = !ENV["HOMEBREW_HELP"].nil? help_flag = false
internal_cmd = true internal_cmd = true
cmd = nil cmd = nil
@ -44,6 +44,9 @@ begin
help_flag = true help_flag = true
elsif !cmd && !help_flag_list.include?(arg) elsif !cmd && !help_flag_list.include?(arg)
cmd = ARGV.delete_at(i) cmd = ARGV.delete_at(i)
elsif help_flag_list.include?(arg) & cmd
# cmd determined, and it needs help
help_flag = true
end end
end end

View File

@ -231,7 +231,7 @@ module Hbc
return if @command == "help" && @args.empty? return if @command == "help" && @args.empty?
unknown_command = @args.empty? ? @command : @args.first unknown_command = @args.empty? ? @command : @args.first
raise ArgumentError, "Unknown command: #{unknown_command}" raise ArgumentError, "Unknown command: #{@command} #{@args.join(" ")}"
end end
def purpose def purpose