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.60.0 lib/avm/source_generators/runner.rb
eac_tools-0.51.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.59.0 lib/avm/source_generators/runner.rb
eac_tools-0.50.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.58.0 lib/avm/source_generators/runner.rb
eac_tools-0.49.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.48.1 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.48.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.47.2 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.47.1 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.47.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.57.0 lib/avm/source_generators/runner.rb
eac_tools-0.46.0 sub/avm/lib/avm/source_generators/runner.rb
avm-0.56.1 lib/avm/source_generators/runner.rb
eac_tools-0.45.2 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.45.1 sub/avm/lib/avm/source_generators/runner.rb
avm-0.56.0 lib/avm/source_generators/runner.rb
eac_tools-0.45.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.44.0 sub/avm/lib/avm/source_generators/runner.rb
eac_tools-0.43.0 sub/avm/lib/avm/source_generators/runner.rb