diff options
| author | Martin Afanasjew | 2016-04-17 04:07:36 +0200 | 
|---|---|---|
| committer | Martin Afanasjew | 2016-04-18 00:52:33 +0200 | 
| commit | f15b631875ef19599bcb4e774d3e67596d1f93ac (patch) | |
| tree | 5f4476eaa9b045453bbd02e37af157d49ee55112 /Library | |
| parent | c6536066dc39da653d265640c6ba6046bb5def98 (diff) | |
| download | brew-f15b631875ef19599bcb4e774d3e67596d1f93ac.tar.bz2 | |
brew.rb: don't show help for 'brew <command> help'
Showing help makes sense for `brew help <command>`, but showing it for
`brew <command> help` is undesirable and prevents all commands from
accepting a named argument `help` (formula, tap, file name, etc.).
All other help flags are still detected before *and* after the command.
Closes #103.
Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/brew.rb | 8 | 
1 files changed, 6 insertions, 2 deletions
diff --git a/Library/brew.rb b/Library/brew.rb index 7207e22b6..38e11473c 100644 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -30,7 +30,7 @@ begin    trap("INT", std_trap) # restore default CTRL-C handler    empty_argv = ARGV.empty? -  help_flag_list = %w[-h --help --usage -? help] +  help_flag_list = %w[-h --help --usage -?]    help_flag = false    internal_cmd = true    cmd = nil @@ -38,7 +38,11 @@ begin    ARGV.dup.each_with_index do |arg, i|      if help_flag && cmd        break -    elsif help_flag_list.include? arg +    elsif help_flag_list.include?(arg) +      # Option-style help: Both `--help <cmd>` and `<cmd> --help` are fine. +      help_flag = true +    elsif arg == "help" && !cmd +      # Command-style help: `help <cmd>` is fine, but `<cmd> help` is not.        help_flag = true      elsif !cmd        cmd = ARGV.delete_at(i)  | 
