Class: Essence::CLI::Add

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/essence/cli/add.rb

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/essence/cli/add.rb', line 12

def call(*args)
  puts "[Essence UI] Fetching..."

  slug = args[0][:component].to_sym
  specification = ::Essence::Client.new.get_component(slug:)
  return puts "[Essence UI] Component not found. Stopping" if specification == ""


  files = specification.dig("artifacts")
  return puts "[Essence UI] Something went wrong. Stopping" unless files

  files.each{ |data| insert_file(slug:, data:) }
  puts "[Essence UI] #{specification.dig("title")} has been successfully added!"
end