diff --git a/README.md b/README.md index 699f08b..94f7502 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,9 @@ Options: ``` Usage: brew cu [CASK] [options] - -a, --all Force upgrade outdated apps including those marked as latest and those that auto-update + -a, --all Include apps that auto-update in the upgrade --cleanup Cleans up cached downloads and tracker symlinks after updating + -f --force Include apps that are marked as latest (i.e. force-reinstall them) -y, --yes Update all outdated apps; answer yes to updating packages ``` diff --git a/cmd/brew-cu.rb b/cmd/brew-cu.rb index 70231b8..197e514 100755 --- a/cmd/brew-cu.rb +++ b/cmd/brew-cu.rb @@ -8,12 +8,15 @@ #: Upgrade a specific app. #: #:OPTIONS: -#: If `--all` or `-a` is passed, force upgrade outdated apps including those -#: marked as latest and those that auto-update. +#: If `--all` or `-a` is passed, include apps that auto-update in the +#: upgrade. #: #: If `--cleanup` is passed, clean up cached downloads and tracker symlinks #: after updating. #: +#: If `--force` or `-f` is passed, include apps that are marked as latest +#: (i.e. force-reinstall them). +#: #: If `--yes` or `-y` is passed, update all outdated apps; answer yes to #: updating packages. diff --git a/lib/bcu.rb b/lib/bcu.rb index faba016..274c5b4 100644 --- a/lib/bcu.rb +++ b/lib/bcu.rb @@ -63,17 +63,22 @@ def self.find_outdated_apps end installed.each do |app| - if options.all && app[:version] == "latest" + version_latest = (app[:version] == "latest") + + if options.force && options.all && version_latest && app[:auto_updates] outdated.push app - state_info[app] = "forced to upgrade" - elsif options.all && app[:auto_updates] && app[:outdated?] + state_info[app] = "forced to reinstall" + elsif options.force && version_latest && !app[:auto_updates] + outdated.push app + state_info[app] = "forced to reinstall" + elsif options.all && !version_latest && app[:auto_updates] && app[:outdated?] outdated.push app state_info[app] = "forced to upgrade" - elsif !options.all && app[:auto_updates] - state_info[app] = "ignored" - elsif app[:outdated?] + elsif !version_latest && !app[:auto_updates] && app[:outdated?] outdated.push app state_info[app] = "outdated" + elsif version_latest || app[:outdated?] + state_info[app] = "ignored" elsif app[:cask].nil? state_info[app] = "no cask available" end diff --git a/lib/bcu/options.rb b/lib/bcu/options.rb index 919ba27..9ea3e5d 100644 --- a/lib/bcu/options.rb +++ b/lib/bcu/options.rb @@ -7,6 +7,7 @@ class << self; attr_accessor :options; end def self.parse!(args) options = OpenStruct.new options.all = false + options.force = false options.cask = nil options.cleanup = false options.dry_run = true @@ -14,7 +15,7 @@ def self.parse!(args) parser = OptionParser.new do |opts| opts.banner = "Usage: brew cu [CASK] [options]" - opts.on("-a", "--all", "Force upgrade outdated apps including those marked as latest and those that auto-update") do + opts.on("-a", "--all", "Include apps that auto-update in the upgrade") do options.all = true end @@ -22,6 +23,10 @@ def self.parse!(args) options.cleanup = true end + opts.on("-f", "--force", "Include apps that are marked as latest (i.e. force-reinstall them)") do + options.force = true + end + opts.on("-y", "--yes", "Update all outdated apps; answer yes to updating packages") do options.dry_run = false end