Class: Oldfixversion::CLI::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/oldfixversion/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].freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Parser.



16
17
18
19
20
21
22
# File 'lib/oldfixversion/cli/parser.rb', line 16

def initialize sections: SECTIONS, client: CLIENT, **dependencies
  super(**dependencies)

  @sections = sections
  @client = client
  @configuration_duplicate = configuration.dup
end

Instance Method Details

#call(arguments = []) ⇒ Object



24
25
26
27
28
# File 'lib/oldfixversion/cli/parser.rb', line 24

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

#to_sObject



30
# File 'lib/oldfixversion/cli/parser.rb', line 30

def to_s = client.to_s