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

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

Overview

Clear local cache

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ace/support/models/cli/commands/cache/clear.rb', line 19

def call(**options)
  cache_manager = Molecules::CacheManager.new
  result = cache_manager.clear

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

  if result[:status] == :success
    puts "Cache cleared successfully"
    puts "Deleted: #{result[:deleted_files].join(", ")}" if result[:deleted_files]&.any?
  else
    raise Ace::Support::Cli::Error.new(result[:message])
  end
rescue => e
  raise Ace::Support::Cli::Error.new(e.message)
end