aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/help.rb8
-rw-r--r--Library/brew.rb4
2 files changed, 10 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index c8fc33430..b8dcad3d5 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -40,6 +40,14 @@ module Homebrew
path = command_path(cmd)
end
+ # Display command-specific (or generic) help in response to `UsageError`.
+ if (error_message = flags[:usage_error])
+ $stderr.puts path ? command_help(path) : HOMEBREW_HELP
+ $stderr.puts
+ onoe error_message
+ exit 1
+ end
+
# Handle `brew` (no arguments).
if flags[:empty_argv]
$stderr.puts HOMEBREW_HELP
diff --git a/Library/brew.rb b/Library/brew.rb
index eb4fe0606..222b432ac 100644
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -118,8 +118,8 @@ rescue FormulaUnspecifiedError
rescue KegUnspecifiedError
abort "This command requires a keg argument"
rescue UsageError
- onoe "Invalid usage"
- abort ARGV.usage
+ require "cmd/help"
+ Homebrew.help cmd, :usage_error => "Invalid usage"
rescue SystemExit => e
onoe "Kernel.exit" if ARGV.verbose? && !e.success?
$stderr.puts e.backtrace if ARGV.debug?