Class: Inspec::Plugin::V2::PluginType::CliCommand

Inherits:
BaseCLI
  • Object
show all
Defined in:
lib/inspec/plugin/v2/plugin_types/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCLI

check_license!, exec_options, exit_on_failure?, format_platform_info, help, profile_options, start, target_options

Constructor Details

#initialize(args, options, config) ⇒ CliCommand

initialize log options for plugins



11
12
13
14
15
16
17
18
# File 'lib/inspec/plugin/v2/plugin_types/cli.rb', line 11

def initialize(args, options, config)
  super(args, options, config)
  class_options = config.fetch(:class_options, nil)
  if class_options
    Inspec::Log.init(class_options["log_location"]) if class_options.key?("log_location")
    Inspec::Log.level = get_log_level(class_options["log_level"]) if class_options.key?("log_level")
  end
end

Class Method Details

.register_with_thorObject

Register the command group with Thor. This must be called on the implementation class AFTER the the cli_command activator has been called



32
33
34
35
36
37
38
39
40
# File 'lib/inspec/plugin/v2/plugin_types/cli.rb', line 32

def self.register_with_thor
  # Figure out my activator name (= subcommand group name)
  subcommand_name = Inspec::Plugin::V2::Registry.instance \
    .find_activators(plugin_type: :cli_command, implementation_class: self) \
    .first.activator_name.to_s

  # Register with Thor
  Inspec::InspecCLI.register(self, subcommand_name, @usage_msg, @desc_msg, {})
end

.subcommand_desc(usage_msg, desc_msg) ⇒ Object

Provide a description for the command group.



25
26
27
28
# File 'lib/inspec/plugin/v2/plugin_types/cli.rb', line 25

def self.subcommand_desc(usage_msg, desc_msg)
  @usage_msg = usage_msg
  @desc_msg = desc_msg
end