Merge pull request #3306 from amyspark/hacktoberfest-quash-cask-help
Fixes querying Cask commands' help
This commit is contained in:
commit
632fdca2d4
@ -78,7 +78,8 @@ begin
|
|||||||
# - a help flag is passed AND a command is matched
|
# - a help flag is passed AND a command is matched
|
||||||
# - a help flag is passed AND there is no command specified
|
# - a help flag is passed AND there is no command specified
|
||||||
# - no arguments are passed
|
# - no arguments are passed
|
||||||
if empty_argv || help_flag
|
# - if cmd is Cask, let Cask handle the help command instead
|
||||||
|
if (empty_argv || help_flag) && cmd != "cask"
|
||||||
require "cmd/help"
|
require "cmd/help"
|
||||||
Homebrew.help cmd, empty_argv: empty_argv
|
Homebrew.help cmd, empty_argv: empty_argv
|
||||||
# `Homebrew.help` never returns, except for external/unknown commands.
|
# `Homebrew.help` never returns, except for external/unknown commands.
|
||||||
@ -116,8 +117,11 @@ begin
|
|||||||
if Process.uid.zero? && !brew_uid.zero?
|
if Process.uid.zero? && !brew_uid.zero?
|
||||||
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}]
|
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}]
|
||||||
end
|
end
|
||||||
|
# Unset HOMEBREW_HELP to avoid confusing the tap
|
||||||
|
ENV.delete("HOMEBREW_HELP") if help_flag
|
||||||
tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap}]
|
tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap}]
|
||||||
safe_system(*tap_commands)
|
safe_system(*tap_commands)
|
||||||
|
ENV["HOMEBREW_HELP"] = "1" if help_flag
|
||||||
exec HOMEBREW_BREW_FILE, cmd, *ARGV
|
exec HOMEBREW_BREW_FILE, cmd, *ARGV
|
||||||
end
|
end
|
||||||
rescue UsageError => e
|
rescue UsageError => e
|
||||||
|
@ -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) unless 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 = @args.empty? ? @command : @args.first
|
raise ArgumentError, "help does not take arguments."
|
||||||
raise ArgumentError, "Unknown command: #{unknown_command}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def purpose
|
def purpose
|
||||||
|
Loading…
x
Reference in New Issue
Block a user