Class: Cliqr::Parser::ParsedInputBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cliqr/parser/parsed_input_builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Builder for collecting parsed command line arguments that can be used to build a command context

Instance Method Summary collapse

Constructor Details

#initialize(config, action_config) ⇒ Cliqr::CLI::Parser::ParsedInputBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new instance

Parameters:

  • config (Cliqr::CLI::Config)

    Configuration settings for the command line interface



17
18
19
20
21
22
23
24
# File 'lib/cliqr/parser/parsed_input_builder.rb', line 17

def initialize(config, action_config)
  @config = config
  @action_config = action_config
  @actions = []
  @options = []
  @option_names = Set.new
  @arguments = []
end

Instance Method Details

#add_argument_token(token) ⇒ Cliqr::Parser::ParsedInputBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add a argument to the list of parsed arguments

Parameters:

  • token (Cliqr::CLI::Parser::ArgumentToken)

    Argument token

Returns:



46
47
48
49
# File 'lib/cliqr/parser/parsed_input_builder.rb', line 46

def add_argument_token(token)
  @arguments.push(token.arg) if token.valid?
  self
end

#add_option_token(token) ⇒ Cliqr::Parser::ParsedInputBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add a new parsed option token from the list of options

arguments

Parameters:

  • token (Cliqr::CLI::Parser::OptionToken)

    A parsed option token from command line

Returns:



32
33
34
35
36
37
38
39
# File 'lib/cliqr/parser/parsed_input_builder.rb', line 32

def add_option_token(token)
  return self unless token.valid?

  add_option_name(token)
  @options.push(token.build)

  self
end

#buildCliqr::Parser::ParsedInput

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build the hash of parsed command line arguments

Returns:



54
55
56
57
58
59
# File 'lib/cliqr/parser/parsed_input_builder.rb', line 54

def build
  ParsedInput.new(:command => @config.name,
                  :actions => @actions,
                  :options => @options,
                  :arguments => @arguments)
end