Class: Umwelt::CLI::Commands::Convey

Inherits:
Hanami::CLI::Command
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/umwelt/cli/commands/convey.rb

Instance Method Summary collapse

Instance Method Details

#call(phase:, semantic:, **options) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/umwelt/cli/commands/convey.rb', line 32

def call(phase:, semantic:, **options)
  puts "Buildung phase: #{phase} with semantic #{semantic}..."

  if phase.to_i.zero?
    puts 'Error: Phase must be an integer'
    return
  end

  @convey = Umwelt::Command::Convey.new.call(
    phase_id: phase.to_i,
    semantic: classify(semantic).to_sym,
    source: Pathname.new(options.fetch(:source)),
    target: Pathname.new(options.fetch(:target))
  )

  if @convey.success?
    @convey.result.each_pair do |key, value|
      puts "#{key} => (#{value})"
    end
    puts "#{@convey.result.keys.count} files written succesfully"
  else
    @convey.errors.each { |e| puts "Error: #{e}" }
  end
end