From 35f2dd3532a409bc4610fdfe54ec375c05ff2e92 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 22 May 2009 00:09:08 +0100 Subject: [PATCH] brew rm command --- Cellar/homebrew/brew | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Cellar/homebrew/brew b/Cellar/homebrew/brew index 68efa9a48a..184d9f9eb5 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]"