Sha256: 742809b2b4fd374d4c178eb12dd69c89965f6fb952a12cdb0e2658e1e0671c84

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

module Rubysmith
  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

3 entries across 3 versions & 1 rubygems

Version Path
rubysmith-0.12.0 lib/rubysmith/cli/parsers/assembler.rb
rubysmith-0.11.0 lib/rubysmith/cli/parsers/assembler.rb
rubysmith-0.10.0 lib/rubysmith/cli/parsers/assembler.rb