Sha256: e0381a314f59f875217b6dfabfaca9cbe70edbeaebe377d8247f26ab9de25786

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module Umwelt::CLI::Commands
  class Convey < Hanami::CLI::Command
    extend Forwardable
    def_delegators Hanami::Utils::String, :classify

    desc 'Convey Phase in Semantic from local Umwelt'

    argument :phase,
             type: :integer,
             required: true,
             desc: 'provide PHASE_ID to imprint'

    argument :semantic,
             type: :string,
             default: 'plain',
             values: %w[plain],
             required: true,
             desc: 'provide SEMANTIC to imprint'

    option :source,
           type: :string,
           default: '.umwelt',
           desc: 'provide folder where source stored'

    option :target,
           type: :string,
           default: 'umwelt',
           desc: 'provide folder for imprint'

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
umwelt-0.1.1 lib/umwelt/cli/commands/convey.rb
umwelt-0.1.0 lib/umwelt/cli/commands/convey.rb