Sha256: b46df2b01824b29951cd3f7f7e1e7407056840ceaae08cee88e607105372da7e

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

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 = []
        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.0.0 lib/sublime_text_kit/cli/parser.rb