If no formula but multiple kegs, advise resolution
In this case the user will simply have to delete all but one keg in order to use the command that uses ARGV.kegs. Refs Homebrew/homebrew#11050.
This commit is contained in:
		
							parent
							
								
									46a9c9b6a0
								
							
						
					
					
						commit
						9ab1df5b68
					
				@ -1,6 +1,6 @@
 | 
			
		||||
module Homebrew extend self
 | 
			
		||||
  def unlink
 | 
			
		||||
    raise FormulaUnspecifiedError if ARGV.named.empty?
 | 
			
		||||
    raise KegUnspecifiedError if ARGV.named.empty?
 | 
			
		||||
 | 
			
		||||
    ARGV.kegs.each do |keg|
 | 
			
		||||
      print "Unlinking #{keg}... "
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,7 @@ module HomebrewArgvExtension
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def kegs
 | 
			
		||||
    rack = nil
 | 
			
		||||
    require 'keg'
 | 
			
		||||
    require 'formula'
 | 
			
		||||
    @kegs ||= downcased_unique_named.collect do |name|
 | 
			
		||||
@ -47,6 +48,15 @@ module HomebrewArgvExtension
 | 
			
		||||
        Keg.new(linked_keg_ref.realpath)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  rescue FormulaUnavailableError
 | 
			
		||||
    if rack
 | 
			
		||||
      raise <<-EOS.undent
 | 
			
		||||
        Multiple kegs installed to #{rack}
 | 
			
		||||
        Please remove all but one and then try again.
 | 
			
		||||
      EOS
 | 
			
		||||
    else
 | 
			
		||||
      raise
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # self documenting perhaps?
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user