Sha256: 57f4e65220912612cc915dcb4167a6ef51567348f68d074a954c49b1ad7ad879

Contents?: true

Size: 737 Bytes

Versions: 7

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

require "optparse"

module SublimeTextKit
  module CLI
    # Assembles and parses all Command Line Interface (CLI) options.
    class Parser
      CLIENT = OptionParser.new nil, 40, "  "

      def initialize configuration = Container[:configuration],
                     section: Parsers::Core,
                     client: CLIENT
        @configuration = configuration.dup
        @section = section
        @client = client
      end

      def call arguments = []
        section.call configuration, client: client
        client.parse arguments
        configuration.freeze
      end

      def to_s = client.to_s

      private

      attr_reader :configuration, :section, :client
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sublime_text_kit-12.3.2 lib/sublime_text_kit/cli/parser.rb
sublime_text_kit-12.3.1 lib/sublime_text_kit/cli/parser.rb
sublime_text_kit-12.3.0 lib/sublime_text_kit/cli/parser.rb
sublime_text_kit-12.2.0 lib/sublime_text_kit/cli/parser.rb
sublime_text_kit-12.1.0 lib/sublime_text_kit/cli/parser.rb
sublime_text_kit-12.0.1 lib/sublime_text_kit/cli/parser.rb
sublime_text_kit-12.0.0 lib/sublime_text_kit/cli/parser.rb