aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/link.rb
diff options
context:
space:
mode:
authorMisty De Meo2012-06-17 16:54:20 -0500
committerMisty De Meo2012-07-09 12:01:09 -0500
commitbf051054b621109aa4e064ec4045f4ce0e521066 (patch)
tree7cd273d7d89b9d75337b894dda3d93bddc266f04 /Library/Homebrew/cmd/link.rb
parent3c5f881e14ddaf2d0a6bb9651e1422ed4cb48185 (diff)
downloadhomebrew-bf051054b621109aa4e064ec4045f4ce0e521066.tar.bz2
link: add --force and --dry-run options
`brew link` can now be made to delete any conflicting files using the --force argument. It also has a --dry-run option, similar to git clean -n, which will list any files which would be deleted without touching the filesystem. Closes #11811. Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
Diffstat (limited to 'Library/Homebrew/cmd/link.rb')
-rw-r--r--Library/Homebrew/cmd/link.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb
index 8ac280c0d..c5e34fe2c 100644
--- a/Library/Homebrew/cmd/link.rb
+++ b/Library/Homebrew/cmd/link.rb
@@ -9,14 +9,30 @@ module Homebrew extend self
abort "Cowardly refusing to `sudo brew link'"
end
+ if ARGV.force?
+ mode = :force
+ elsif ARGV.include?("--dry-run") || ARGV.include?("-n")
+ mode = :dryrun
+ else
+ mode = nil
+ end
+
ARGV.kegs.each do |keg|
if keg.linked_keg_record.directory? and keg.linked_keg_record.realpath == keg
opoo "Already linked: #{keg}"
next
end
+ if mode == :dryrun
+ print "Would remove:\n" do
+ keg.link(mode)
+ end
+
+ next
+ end
+
print "Linking #{keg}... " do
- puts "#{keg.link} symlinks created"
+ puts "#{keg.link(mode)} symlinks created"
end
end
end