aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMisty De Meo2012-06-17 16:54:20 -0500
committerMisty De Meo2012-07-09 12:01:09 -0500
commit743b5e6feb05c92cfea49f89bc946ea1420b80fe (patch)
tree97b06b997d1e4e0c495f061918542f266461dce5 /Library/Homebrew/cmd
parentdd9ef7b71b71193cc5284732fe26d62f9b25263c (diff)
downloadbrew-743b5e6feb05c92cfea49f89bc946ea1420b80fe.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 Homebrew/homebrew#11811. Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
Diffstat (limited to 'Library/Homebrew/cmd')
-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