diff --git a/lib/bcu/command/upgrade.rb b/lib/bcu/command/upgrade.rb index 4256a3d..57b838a 100644 --- a/lib/bcu/command/upgrade.rb +++ b/lib/bcu/command/upgrade.rb @@ -56,19 +56,29 @@ def run_process(_args, options) # In interactive flow we're not sure if we need to clean up cleanup_necessary = !options.interactive + batched = [] + outdated.each do |app| + upgrade app, options, state_info, batched + end + + # upgrade deferred applications + tmp_flag = options.interactive + options.interactive = false + batched.each do |app| upgrade app, options, state_info end + options.interactive = tmp_flag system "brew", "cleanup", options.verbose ? "--verbose": "" if options.cleanup && cleanup_necessary end private - def upgrade(app, options, state_info) + def upgrade(app, options, state_info, batched = []) if options.interactive formatting = Formatter.formatting_for_app(state_info, app, options) - printf 'Do you want to upgrade "%s", [p]in it to exclude it from updates or [q]uit [y/p/q/N]? ', + printf 'Do you want to upgrade "%s", [p]in it to exclude it from updates or [q]uit or [b]atched update [y/p/q/b/N]? ', app: Formatter.colorize(app[:token], formatting[0]) input = $stdin.gets.strip @@ -83,6 +93,11 @@ def upgrade(app, options, state_info) exit 0 if input.casecmp("q").zero? # rubocop:enable Rails/Exit + if input.casecmp("b").zero? + batched.push app + return + end + return unless input.casecmp("y").zero? end