Sha256: d64d9d510d7cb14eebb9cd6a8d3e0aa28691d9a725350097edd5544fedb03aed

Contents?: true

Size: 830 Bytes

Versions: 8

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

require "optparse"

module Git
  module Lint
    module CLI
      # Assembles and parses all Command Line Interface (CLI) options.
      class Parser
        CLIENT = OptionParser.new nil, 40, "  "
        SECTIONS = [Parsers::Core, Parsers::Analyze].freeze # Order matters.

        def initialize sections: SECTIONS, client: CLIENT, container: Container
          @sections = sections
          @client = client
          @configuration = container[:configuration].dup
        end

        def call arguments = []
          sections.each { |section| section.call configuration, client: }
          client.parse arguments
          configuration.freeze
        end

        def to_s = client.to_s

        private

        attr_reader :sections, :client, :configuration
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-lint-3.3.2 lib/git/lint/cli/parser.rb
git-lint-3.3.1 lib/git/lint/cli/parser.rb
git-lint-3.3.0 lib/git/lint/cli/parser.rb
git-lint-3.2.0 lib/git/lint/cli/parser.rb
git-lint-3.1.0 lib/git/lint/cli/parser.rb
git-lint-3.0.2 lib/git/lint/cli/parser.rb
git-lint-3.0.1 lib/git/lint/cli/parser.rb
git-lint-3.0.0 lib/git/lint/cli/parser.rb