Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add batched update option for interactive mode #195

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/bcu/command/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
ondrejfuhrer marked this conversation as resolved.
Show resolved Hide resolved
batched.each do |app|
upgrade app, options, state_info
end

Expand All @@ -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 "%<app>s", [p]in it to exclude it from updates or [q]uit [y/p/q/N]? ',
printf 'Do you want to upgrade "%<app>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

Expand All @@ -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

Expand Down