diff options
Diffstat (limited to 'Library/brew.rb')
| -rw-r--r-- | Library/brew.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/Library/brew.rb b/Library/brew.rb index 4b789a490..4c7cc8d65 100644 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -69,15 +69,27 @@ begin # It should never affect external commands so they can handle usage # arguments themselves. - if empty_argv || (help_flag && (cmd.nil? || internal_cmd)) - # TODO: - `brew help cmd` should display subcommand help - require "cmd/help" - if empty_argv - $stderr.puts ARGV.usage - else + if empty_argv + $stderr.puts ARGV.usage + exit 1 + elsif help_flag + if cmd.nil? puts ARGV.usage + exit 0 + else + # Handle both internal ruby and shell commands + require "cmd/help" + help_text = Homebrew.help_for_command(cmd) + if help_text.nil? + # External command, let it handle help by itself + elsif help_text.empty? + puts "No help available for #{cmd}" + exit 1 + else + puts help_text + exit 0 + end end - exit ARGV.any? ? 0 : 1 end if internal_cmd |
