class Tocer::CLI::Parsers::Build

Handles parsing of Command Line Interface (CLI) build options.

Attributes

client[R]
configuration[R]
options[R]

Public Class Methods

call(options: {}) click to toggle source
# File lib/tocer/cli/parsers/build.rb, line 8
def self.call options: {}, configuration: Configuration::Loader.call, client: CLIENT
  new(options: options, configuration: configuration, client: client).call
end
new(options: {}) click to toggle source
# File lib/tocer/cli/parsers/build.rb, line 12
def initialize options: {}, configuration: Configuration::Loader.call, client: CLIENT
  @options = options
  @configuration = configuration
  @client = client
end

Public Instance Methods

call(arguments = []) click to toggle source
# File lib/tocer/cli/parsers/build.rb, line 18
def call arguments = []
  client.separator "\nBUILD OPTIONS:\n"
  private_methods.sort.grep(/add_/).each { |method| __send__ method }
  arguments.empty? ? arguments : client.parse!(arguments)
end

Private Instance Methods

add_include() click to toggle source
# File lib/tocer/cli/parsers/build.rb, line 38
def add_include
  client.on(
    "-i",
    "--includes [a,b,c]",
    Array,
    %(Include pattern list. Default: #{CLI::Configuration::Loader.call.includes}.)
  ) do |value|
    list = Array value
    options[:includes] = list.empty? ? configuration.to_h.fetch(:includes) : list
  end
end
add_label() click to toggle source
# File lib/tocer/cli/parsers/build.rb, line 28
def add_label
  client.on(
    "-l",
    "--label [LABEL]",
    %(Label. Default: "#{CLI::Configuration::Loader.call.label}".)
  ) do |value|
    options[:label] = value || configuration.to_h.fetch(:label)
  end
end