diff options
| author | Martin Afanasjew | 2016-04-19 07:33:13 +0200 | 
|---|---|---|
| committer | Martin Afanasjew | 2016-04-20 13:46:10 +0200 | 
| commit | cf3486f98a5ddc8eae3c511f759471eff79cfcf8 (patch) | |
| tree | f6436298ffd6347b2480e192c8d8d05e61f64f4e /Library/Homebrew/cmd/help.rb | |
| parent | 557ad956fdd9e3f403ea743d55a066341fab8132 (diff) | |
| download | brew-cf3486f98a5ddc8eae3c511f759471eff79cfcf8.tar.bz2 | |
help: show command-specific help for invalid usage
Instead of always printing the generic help text, print command-specific
help if it is available and a command raised the `UsageError` exception.
Put the error message underneath the help text (was above) to avoid that
it scrolls off the screen.
Thereby fix a regression where handling the invalid usage would fail to
access `ARGV.usage` removed in c6536066dc39da653d265640c6ba6046bb5def98.
Diffstat (limited to 'Library/Homebrew/cmd/help.rb')
| -rw-r--r-- | Library/Homebrew/cmd/help.rb | 8 | 
1 files changed, 8 insertions, 0 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 | 
