Let Cask handle the -h flag

This commit is contained in:
L. E. Segovia 2017-10-20 16:51:26 -03:00
parent 95a3d53125
commit 75de4db003
2 changed files with 9 additions and 4 deletions

View File

@ -80,7 +80,13 @@ begin
# - no arguments are passed # - no arguments are passed
if empty_argv || help_flag if empty_argv || help_flag
require "cmd/help" require "cmd/help"
Homebrew.help cmd, empty_argv: empty_argv if cmd == "cask"
# Let Cask handle the help command
Homebrew.send cmd.to_s.tr("-", "_").downcase
exit 0
else
Homebrew.help cmd, empty_argv: empty_argv
end
# `Homebrew.help` never returns, except for external/unknown commands. # `Homebrew.help` never returns, except for external/unknown commands.
end end

View File

@ -154,7 +154,7 @@ module Hbc
def run def run
command_name, *args = detect_command_and_arguments(*@args) command_name, *args = detect_command_and_arguments(*@args)
command = if help? command = if help?
args.unshift(command_name) args.unshift(command_name) if !command_name.nil?
"help" "help"
else else
self.class.lookup_command(command_name) self.class.lookup_command(command_name)
@ -230,8 +230,7 @@ module Hbc
return if @command == "help" && @args.empty? return if @command == "help" && @args.empty?
unknown_command = (@command == "help") ? @args.first : @command raise ArgumentError, "help does not take arguments"
raise ArgumentError, "Unknown command: #{unknown_command}"
end end
def purpose def purpose