Class: Cliqr::Command::CommandContextBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cliqr/command/command_context.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 creating a instance of CommandContext from parsed cli arguments

Instance Method Summary collapse

Constructor Details

#initialize(config, parsed_input, options, executor) ⇒ Cliqr::Command::CommandContextBuilder

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 builder for CommandContext

Parameters:

  • config (Cliqr::Command::Config)

    The configuration settings

  • parsed_input (Cliqr::Parser::ParsedInput)

    Parsed and validated command line arguments

  • options (Hash)

    Options for command execution

  • executor (Proc)

    Executes forwarded commands



185
186
187
188
189
190
# File 'lib/cliqr/command/command_context.rb', line 185

def initialize(config, parsed_input, options, executor)
  @config = config
  @parsed_input = parsed_input
  @options = options
  @executor = executor
end

Instance Method Details

#buildCliqr::Command::CommandContext

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 a new instance of CommandContext

Returns:



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/cliqr/command/command_context.rb', line 195

def build
  option_contexts = @parsed_input.options.map do |option|
    CommandOption.new(option, @config.option(option.first))
  end

  CommandContext.new @config,
                     option_contexts,
                     @parsed_input.arguments,
                     @options[:environment],
                     @executor
end