From 4c622d114ab8d4f8a2d4188dbcdca41504b8ae9d Mon Sep 17 00:00:00 2001 From: XOR-op <17672363+XOR-op@users.noreply.github.com> Date: Sun, 13 Feb 2022 12:20:48 +0800 Subject: [PATCH 1/2] Add batched update option for interactive mode --- lib/bcu/command/upgrade.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/bcu/command/upgrade.rb b/lib/bcu/command/upgrade.rb index 4256a3d..4c84c77 100644 --- a/lib/bcu/command/upgrade.rb +++ b/lib/bcu/command/upgrade.rb @@ -56,7 +56,15 @@ 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 + options.interactive = false + batched.each do |app| upgrade app, options, state_info end @@ -65,10 +73,10 @@ def run_process(_args, options) 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 +91,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 From c1d6be19176eeb52ee96d7fee7c1a038d9202b0c Mon Sep 17 00:00:00 2001 From: XOR-op <17672363+XOR-op@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:59:20 +0800 Subject: [PATCH 2/2] recover options.interactive --- lib/bcu/command/upgrade.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bcu/command/upgrade.rb b/lib/bcu/command/upgrade.rb index 4c84c77..57b838a 100644 --- a/lib/bcu/command/upgrade.rb +++ b/lib/bcu/command/upgrade.rb @@ -63,10 +63,12 @@ def run_process(_args, options) 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