Class: Cliqr::Parser::ParsedInputBuilder Private
- Inherits:
-
Object
- Object
- Cliqr::Parser::ParsedInputBuilder
- 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
-
#add_argument_token(token) ⇒ Cliqr::Parser::ParsedInputBuilder
private
Add a argument to the list of parsed arguments.
-
#add_option_token(token) ⇒ Cliqr::Parser::ParsedInputBuilder
private
Add a new parsed option token from the list of options.
-
#build ⇒ Cliqr::Parser::ParsedInput
private
Build the hash of parsed command line arguments.
-
#initialize(config, action_config) ⇒ Cliqr::CLI::Parser::ParsedInputBuilder
constructor
private
Initialize a new instance.
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
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
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
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 |
#build ⇒ Cliqr::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
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 |