Sha256: fc72056e729ae64d9ec509d6401747e6f212ba4d15d7dbcc957e1f69bcb25698

Contents?: true

Size: 931 Bytes

Versions: 4

Compression:

Stored size: 931 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, **)
          super(**)
          @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

4 entries across 4 versions & 1 rubygems

Version Path
git-lint-5.3.0 lib/git/lint/cli/parser.rb
git-lint-5.2.0 lib/git/lint/cli/parser.rb
git-lint-5.1.2 lib/git/lint/cli/parser.rb
git-lint-5.1.1 lib/git/lint/cli/parser.rb