Class: BundleUpdateInteractive::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_update_interactive/cli.rb,
lib/bundle_update_interactive/cli/row.rb,
lib/bundle_update_interactive/cli/table.rb,
lib/bundle_update_interactive/cli/options.rb,
lib/bundle_update_interactive/cli/multi_select.rb

Defined Under Namespace

Classes: MultiSelect, Options, Row, Table

Instance Method Summary collapse

Instance Method Details

#run(argv: ARGV) ⇒ Object

rubocop:disable Metrics/AbcSize



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bundle_update_interactive/cli.rb', line 7

def run(argv: ARGV) # rubocop:disable Metrics/AbcSize
  options = Options.parse(argv)
  report, updater = generate_report(options)

  puts_legend_and_withheld_gems(report) unless report.empty?
  puts("No gems to update.").then { return } if report.updatable_gems.empty?

  selected_gems = MultiSelect.prompt_for_gems_to_update(report.updatable_gems)
  puts("No gems to update.").then { return } if selected_gems.empty?

  puts "Updating the following gems."
  puts Table.updatable(selected_gems).render
  puts

  if options.commit?
    GitCommitter.new(updater).apply_updates_as_individual_commits(*selected_gems.keys)
  else
    updater.apply_updates(*selected_gems.keys)
  end

  puts_gemfile_modified_notice if updater.modified_gemfile?
rescue Exception => e # rubocop:disable Lint/RescueException
  handle_exception(e)
end