blob: adf091709422030dd08aa8637a6e142c9001ca7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  | 
#:  * `unlink` [`--dry-run`] <formula>:
#:    Remove symlinks for <formula> from the Homebrew prefix. This can be useful
#:    for temporarily disabling a formula:
#:    `brew unlink foo && commands && brew link foo`.
#:
#:    If `--dry-run` or `-n` is passed, Homebrew will list all files which would
#:    be unlinked, but will not actually unlink or delete any files.
require "ostruct"
module Homebrew
  def unlink
    raise KegUnspecifiedError if ARGV.named.empty?
    mode = OpenStruct.new
    mode.dry_run = true if ARGV.dry_run?
    ARGV.kegs.each do |keg|
      if mode.dry_run
        puts "Would remove:"
        keg.unlink(mode)
        next
      end
      keg.lock do
        print "Unlinking #{keg}... "
        puts if ARGV.verbose?
        puts "#{keg.unlink(mode)} symlinks removed"
      end
    end
  end
end
  |