Class: Ace::Handbook::CLI::Commands::Sync

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/handbook/cli/commands/sync.rb

Instance Method Summary collapse

Constructor Details

#initialize(syncer: nil) ⇒ Sync

Returns a new instance of Sync.



15
16
17
18
# File 'lib/ace/handbook/cli/commands/sync.rb', line 15

def initialize(syncer: nil)
  super()
  @syncer = syncer || Ace::Handbook::Organisms::ProviderSyncer.new
end

Instance Method Details

#call(provider: nil, quiet: false) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ace/handbook/cli/commands/sync.rb', line 20

def call(provider: nil, quiet: false, **)
  results = @syncer.sync(provider: provider)
  return if quiet

  results.each do |result|
    puts "synced #{result[:provider]} -> #{result[:relative_output_dir]} " \
         "(#{result[:projected_skills]} skills, #{result[:updated_files]} updated, " \
         "#{result[:removed_entries]} removed)"
  end
  print_inventory_summary(results)
rescue => e
  raise Ace::Support::Cli::Error.new(e.message)
end