From 2ba69c31e98d0c90b40c6c38d4dfaa27c25745dd Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Thu, 30 Jul 2015 07:45:56 +0100 Subject: [PATCH] autoupdate: version 1.1.0 Changes: * No longer automatically upgrades all your packages by default. You can regain this behaviour by passing `--upgrade` to the command. * Default behaviour is to now run `brew update` once every 24 hours. * You can now access the command summary by passing `--help` or `-h` as well as nothing. * Added versioning to make it slightly clearer when the autoupdate command changes. Future plans: * Ability to pass specific formulae to the command so you can upgrade those automatically & selectively. * Ability to choose how often the autoupdate is run. 24 hours will remain the default, but choice is good. Welcome ideas on improvement if you have any specific requests/ideas/etc. Closes #1. --- cmd/brew-autoupdate.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/brew-autoupdate.rb b/cmd/brew-autoupdate.rb index f4e2224aebf40..75f3ae8376079 100755 --- a/cmd/brew-autoupdate.rb +++ b/cmd/brew-autoupdate.rb @@ -5,19 +5,28 @@ module Homebrew def autoupdate - path = File.expand_path("~/Library/LaunchAgents/homebrew.mxcl.autoupdate.plist") - if ARGV.empty? + if ARGV.empty? || ARGV.include?("--help") || ARGV.include?("-h") puts <<-EOS.undent Usage: --start = Start autoupdating every 24 hours. --stop = Stop autoupdating, but retain plist & logs. --delete = Cancel the autoupdate, delete the plist and logs. + --upgrade = Also automatically upgrade your packages. + --version = Output this tool's current version. EOS end + if ARGV.include? "--version" + puts "Version 1.1.0, July 2015" + end + if ARGV.include? "--start" + auto_args = "#{HOMEBREW_PREFIX}/bin/brew update" + # Spacing at start of line is deliberate. Don't undo. + auto_args << " && #{HOMEBREW_PREFIX}/bin/brew upgrade -v" if ARGV.include? "--upgrade" + file = <<-EOS.undent @@ -29,7 +38,7 @@ def autoupdate /bin/sh -c - /bin/date && #{HOMEBREW_PREFIX}/bin/brew update && #{HOMEBREW_PREFIX}/bin/brew upgrade -v + /bin/date && #{auto_args} RunAtLoad