Class: Plz::CommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/plz/command_builder.rb

Constant Summary collapse

SCHEMA_FILE_PATH_PATTERN =
"schema.{json,yml}"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CommandBuilder

Returns a new instance of CommandBuilder.

Parameters:

  • argv (Array<String>)

    Raw ARGV



23
24
25
# File 'lib/plz/command_builder.rb', line 23

def initialize(argv)
  @argv = argv
end

Class Method Details

.call(arguments) ⇒ Plz::Command, Plz::ErrorCommand

Note:

This is a shortcut for #call method

Builds callable command object from given ARGV

Examples:

Plz::CommandBuilder.call(ARGV).call

Returns:



10
11
12
# File 'lib/plz/command_builder.rb', line 10

def self.call(arguments)
  new(arguments).call
end

Instance Method Details

#callPlz::Command

Returns Callable command object.

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/plz/command_builder.rb', line 28

def call
  exit_if_help
  validate!
  Command.new(
    method: method,
    base_url: base_url,
    path: path,
    headers: headers,
    params: request_params,
    options: options,
  )
rescue Error => error
  ErrorCommand.new(error)
end