Sha256: 408b2189138ae6dc0c60a5c430df0ca5edae60266642bd1b1f965499c87f5aed

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

require "runcom"

module Tocer
  module CLI
    module Parsers
      SECTIONS = [Core, Build].freeze # Order is important.

      # Assembles and parses all Command Line Interface (CLI) options.
      class Assembler
        def initialize configuration: CLI::Configuration::Loader.call,
                       sections: SECTIONS,
                       client: CLIENT
          @options = configuration.to_h
          @sections = sections
          @client = client
        end

        def call arguments = []
          sections.each { |parser| parser.call client: client, options: options }
          client.parse! arguments
          options
        end

        def to_h = options

        def to_s = client.to_s

        private

        attr_reader :options, :client, :sections
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tocer-12.0.0 lib/tocer/cli/parsers/assembler.rb