aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorSamuel John2013-07-23 10:55:07 +0200
committerSamuel John2013-08-14 22:25:03 +0200
commitcae03e33630ccae6d3b11e63f5fe6a61d8b989ea (patch)
treea3dfc1920b105563577656fbba129b61ddfe8458 /Library/Homebrew/cmd
parentad80b10de4aaeb2aaa64f082b349f39f27fc60d7 (diff)
downloadbrew-cae03e33630ccae6d3b11e63f5fe6a61d8b989ea.tar.bz2
brew reinstall: Reuse options from last time
Now, we can finally stop stuggesting to `brew rm <foo>` and then `brew install <foo> <with-your-preferred options> So `brew reinstall` will honor all options that have been recorded into the INSTALL_RECEIPT.json plus if `--build-bottle` was used.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/reinstall.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb
index 6e9b7b339..e7abd8d4d 100644
--- a/Library/Homebrew/cmd/reinstall.rb
+++ b/Library/Homebrew/cmd/reinstall.rb
@@ -3,7 +3,23 @@ require 'cmd/install'
module Homebrew extend self
def reinstall
- self.uninstall
- self.install
+ # At first save the named formulae and remove them from ARGV
+ named = ARGV.named
+ ARGV.delete_if { |arg| named.include? arg }
+ clean_ARGV = ARGV.clone
+
+ # Add the used_options for each named formula separately so
+ # that the options apply to the right formula.
+ named.each do |name|
+ ARGV.replace(clean_ARGV)
+ ARGV << name
+ tab = Tab.for_name(name)
+ tab.used_options.each { |option| ARGV << option.to_s }
+ ARGV << '--build-bottle' if tab.built_as_bottle
+ # Todo: Be as smart as upgrade to restore the old state if reinstall fails.
+ self.uninstall
+ oh1 "Reinstalling #{name} #{ARGV.options_only*' '}"
+ self.install
+ end
end
end