module Runbook::CLIBase

Public Class Methods

included(base) click to toggle source
# File lib/runbook/cli_base.rb, line 2
def self.included(base)
  base.extend(ClassMethods)

  base.check_unknown_options!

  base.class_option(
    :config,
    aliases: "-c",
    type: :string,
    group: :base,
    desc: "Path to runbook config file"
  )
end
new(args = [], local_options = {}, config = {}) click to toggle source
Calls superclass method
# File lib/runbook/cli_base.rb, line 16
def initialize(args = [], local_options = {}, config = {})
  super(args, local_options, config)

  cmd_name = config[:current_command].name
  _set_cli_config(options[:config], cmd_name) if options[:config]
end

Protected Instance Methods

_set_cli_config(config, cmd) click to toggle source
# File lib/runbook/cli_base.rb, line 31
def _set_cli_config(config, cmd)
  unless File.exist?(config)
    raise Thor::InvocationError, "#{cmd}: cannot access #{config}: No such file or directory"
  end
  Runbook::Configuration.cli_config_file = config
  Runbook::Configuration.reconfigure
end