Sha256: ddd2e5055531844acbd664ad66b62ead0d53b3fc10f553c27683819dd4181c43

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

require "core"
require "optparse"

module Git
  module Lint
    module CLI
      # Assembles and parses all Command Line Interface (CLI) options.
      class Parser
        include Import[:configuration]

        CLIENT = OptionParser.new nil, 40, "  "
        SECTIONS = [Parsers::Core, Parsers::Analyze].freeze # Order matters.

        def initialize sections: SECTIONS, client: CLIENT, **dependencies
          super(**dependencies)
          @sections = sections
          @client = client
          @configuration_duplicate = configuration.dup
        end

        def call arguments = Core::EMPTY_ARRAY
          sections.each { |section| section.call configuration_duplicate, client: }
          client.parse arguments
          configuration_duplicate.freeze
        end

        def to_s = client.to_s

        private

        attr_reader :sections, :client, :configuration_duplicate
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git-lint-5.1.0 lib/git/lint/cli/parser.rb