Sha256: cf3d97ad2931b7f830fd2024e0f1e8729b143d116f83cc900782b16ccce48551

Contents?: true

Size: 1.23 KB

Versions: 159

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'avm/registry'
require 'eac_cli/core_ext'

module Avm
  module SourceGenerators
    class Runner
      OPTION_NAME_VALUE_SEPARATOR = ':'

      runner_with :help do
        arg_opt '-o', '--option', 'Option for generator.', repeat: true, optional: true
        pos_arg :stereotype_name
        pos_arg :target_path
      end

      def run
        start_banner
        generate
      end

      def generate
        infom 'Generating...'
        generator.perform
        success "Source generated in \"#{generator.target_path}\""
      end

      def start_banner
        infov 'Stereotype', stereotype_name
        infov 'Target path', target_path
        infov 'Generator', generator.class
      end

      def generator_uncached
        ::Avm::Registry.source_generators
          .detect_optional(stereotype_name, target_path, options) ||
          fatal_error("No generator found for stereotype \"#{stereotype_name}\"")
      end

      delegate :stereotype_name, to: :parsed

      # @return [Hash<String, String>]
      def options
        parsed.option.map { |v| v.split(OPTION_NAME_VALUE_SEPARATOR) }.to_h
      end

      def target_path
        parsed.target_path.to_pathname
      end
    end
  end
end

Version data entries

159 entries across 159 versions & 2 rubygems

Version Path
avm-0.83.0 lib/avm/source_generators/runner.rb
eac_tools-0.82.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.82.0 lib/avm/source_generators/runner.rb
eac_tools-0.81.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.80.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.81.0 lib/avm/source_generators/runner.rb
eac_tools-0.79.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.80.0 lib/avm/source_generators/runner.rb
eac_tools-0.78.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.77.1 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.77.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.76.1 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.76.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.75.2 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.75.1 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.75.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.74.1 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.74.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.79.0 lib/avm/source_generators/runner.rb
eac_tools-0.73.0 sub/avm/lib/avm/source_generators/runner.rb