Sha256: 24b8ed263a5ee941a3d007b683c687a6896276cc05303ffadbef1108a669042b

Contents?: true

Size: 828 Bytes

Versions: 6

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

module Tocer
  module CLI
    module Parsers
      # Assembles and parses all Command Line Interface (CLI) options.
      class Assembler
        SECTIONS = [Core, Build].freeze # Order is important.

        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, :sections, :client
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tocer-12.2.0 lib/tocer/cli/parsers/assembler.rb
tocer-12.1.0 lib/tocer/cli/parsers/assembler.rb
tocer-12.0.4 lib/tocer/cli/parsers/assembler.rb
tocer-12.0.3 lib/tocer/cli/parsers/assembler.rb
tocer-12.0.2 lib/tocer/cli/parsers/assembler.rb
tocer-12.0.1 lib/tocer/cli/parsers/assembler.rb