Class: Rubysmith::CLI::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysmith/cli/parser.rb

Overview

Assembles and parses all Command Line Interface (CLI) options.

Constant Summary collapse

CLIENT =
OptionParser.new nil, 40, "  "
SECTIONS =

Order is important.

[Parsers::Core, Parsers::Build].freeze

Instance Method Summary collapse

Constructor Details

#initialize(sections: SECTIONS, client: CLIENT) ⇒ Parser

Returns a new instance of Parser.



15
16
17
18
19
20
# File 'lib/rubysmith/cli/parser.rb', line 15

def initialize(sections: SECTIONS, client: CLIENT, **)
  super(**)
  @sections = sections
  @client = client
  @configuration_duplicate = configuration.dup
end

Instance Method Details

#call(arguments = Core::EMPTY_ARRAY) ⇒ Object



22
23
24
25
26
# File 'lib/rubysmith/cli/parser.rb', line 22

def call arguments = Core::EMPTY_ARRAY
  sections.each { |section| section.call configuration_duplicate, client: }
  client.parse arguments
  configuration_duplicate.freeze
end

#to_sObject



28
# File 'lib/rubysmith/cli/parser.rb', line 28

def to_s = client.to_s