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



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

def call(*args)
  component_name = args[0][:component_name]

  return puts "> #{component_name}: component unsupported" unless Essence.component_names.include?(component_name.to_sym)

  Essence::CLI::Commands.copy_component(component_name:)
  Essence::CLI::Commands.replace_component_contents(component_name:)
  Essence::CLI::Commands.replace_component_contents(
    component_name:,
    from: Essence::CLI::Commands::COMPONENT_DEFINITION_SUFFIX,
    to: Essence::CLI::Commands::PHLEX_COMPONENT_DEFINITION_SUFFIX
  )

  puts "> Successfully added #{component_name} component to #{Essence::CLI::Commands::DESTINATION_DIR.join("#{component_name}.rb")}"
end