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

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

Overview

Fetch models from models.dev API

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ace/support/models/cli/commands/cache/sync.rb', line 26

def call(**options)
  result = Organisms::SyncOrchestrator.new.sync(force: options[:force])

  if options[:json]
    puts JSON.pretty_generate(result)
    return
  end

  case result[:status]
  when :success
    puts result[:message]
    puts "Duration: #{result[:duration]}s"
  when :skipped
    puts result[:message]
    puts "Last synced: #{result[:last_sync_at]}"
  when :error
    raise Ace::Support::Cli::Error.new(result[:message])
  end
end