Sha256: 5de5ac84372972f167431d0edc222d85df9d46f69bf340605396568129eb6e07

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

require "core"
require "optparse"

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

      CLIENT = OptionParser.new nil, 40, "  "

      def initialize section: Parsers::Core, client: CLIENT, **dependencies
        super(**dependencies)
        @section = section
        @client = client
        @configuration_duplicate = configuration.dup
      end

      def call arguments = Core::EMPTY_ARRAY
        section.call(configuration_duplicate, client:)
        client.parse arguments
        configuration_duplicate.freeze
      end

      def to_s = client.to_s

      private

      attr_reader :section, :client, :configuration_duplicate
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sublime_text_kit-14.1.0 lib/sublime_text_kit/cli/parser.rb