Class: Ace::Support::Models::CLI::Commands::Providers::Sync

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

Overview

Sync provider YAML configs with native catalogs or models.dev.

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ace/support/models/cli/commands/providers/sync.rb', line 34

def call(**options)
  orchestrator = Organisms::ProviderSyncOrchestrator.new

  result = orchestrator.sync(
    config_dir: options[:config_dir],
    provider: options[:provider],
    apply: options[:apply],
    commit: options[:commit],
    show_all: options[:all],
    since: options[:since]
  )

  if result[:status] == :error
    raise Ace::Support::Cli::Error.new(result[:message])
  end

  if result[:apply_errors]&.any?
    raise Ace::Support::Cli::Error.new(result[:apply_errors].join("; "))
  end

  if options[:json]
    puts JSON.pretty_generate(result)
  else
    puts orchestrator.format_result(result)
  end
rescue CacheError => e
  raise Ace::Support::Cli::Error.new("#{e.message}. Run 'ace-models sync' first to download model data.")
rescue ConfigError => e
  raise Ace::Support::Cli::Error.new("Config error: #{e.message}")
end