tap: improve arguments resolution

* Use `ARGV.include?` instead of `ARGV.first ==`, so users can pass
  `-v`/`-d` before the function flags(i.e. `--list-pinned` etc)
* Restore the ability to call `brew tap --flags tap/name`.
This commit is contained in:
Xu Cheng 2015-12-26 13:01:52 +08:00
parent 68361be36c
commit c318a9a03e

View File

@ -3,18 +3,18 @@ require "core_formula_repository"
module Homebrew module Homebrew
def tap def tap
if ARGV.empty? if ARGV.include? "--repair"
puts Tap.names
elsif ARGV.first == "--repair"
Tap.each(&:link_manpages) Tap.each(&:link_manpages)
migrate_taps :force => true migrate_taps :force => true
elsif ARGV.first == "--list-official" elsif ARGV.include? "--list-official"
require "official_taps" require "official_taps"
puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" } puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" }
elsif ARGV.first == "--list-pinned" elsif ARGV.include? "--list-pinned"
puts Tap.select(&:pinned?).map(&:name) puts Tap.select(&:pinned?).map(&:name)
elsif ARGV.named.empty?
puts Tap.names
else else
tap = Tap.fetch(ARGV[0]) tap = Tap.fetch(ARGV.named[0])
begin begin
tap.install(:clone_target => ARGV.named[1], tap.install(:clone_target => ARGV.named[1],
:full_clone => ARGV.include?("--full")) :full_clone => ARGV.include?("--full"))