aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2009-05-22 00:09:08 +0100
committerMax Howell2009-05-22 00:15:48 +0100
commit35f2dd3532a409bc4610fdfe54ec375c05ff2e92 (patch)
tree414fdd38440e45b2f4605a61d82e20f7e2acc0cf
parented0f997d18802f833711888f2f5f2f57979e1aaf (diff)
downloadbrew-35f2dd3532a409bc4610fdfe54ec375c05ff2e92.tar.bz2
brew rm command
-rwxr-xr-xCellar/homebrew/brew27
1 files changed, 19 insertions, 8 deletions
diff --git a/Cellar/homebrew/brew b/Cellar/homebrew/brew
index 68efa9a48..184d9f9eb 100755
--- a/Cellar/homebrew/brew
+++ b/Cellar/homebrew/brew
@@ -5,6 +5,17 @@ require 'find'
require 'pathname'
$root = Pathname.new(__FILE__).realpath.dirname.parent.parent
+def prune
+ $root.find do |path|
+ if path.directory?
+ name=path.basename
+ Find.prune if name == 'Cellar' or name == 'Formula'
+ elsif path.symlink?
+ path.unlink unless path.readlink.exist?
+ end
+ end
+end
+
case ARGV[0]
when 'brew', 'install' then
abort "You must specify a Formula" unless ARGV[1]
@@ -13,6 +24,13 @@ case ARGV[0]
file+='.rb' unless File.exist? file
system "ruby #{file} #{ARGV.join ' '}"
+ when 'rm' then
+ path=$root+'Cellar'+ARGV[1]
+ abort "#{ARGV[1]} is not installed" unless path.directory?
+ path.rmtree
+ prune
+ puts "#{path} removed"
+
when 'ln' then
abort "#{ARGV[1]} is not a directory" unless File.directory? ARGV[1]
@@ -35,14 +53,7 @@ case ARGV[0]
end
when 'prune', 'pasteurize' then
- $root.find do |path|
- if path.directory?
- name=path.basename
- Find.prune if name == 'Cellar' or name == 'Formula'
- elsif path.symlink?
- path.unlink unless path.readlink.exist?
- end
- end
+ prune
else
puts "usage: #{$0} [prune] [ln path] [install pkg]"