Method: Inspec::Plugin::V2::Loader#activate_mentioned_cli_plugins
- Defined in:
- lib/inspec/plugin/v2/loader.rb
#activate_mentioned_cli_plugins(cli_args = ARGV) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/inspec/plugin/v2/loader.rb', line 84 def activate_mentioned_cli_plugins(cli_args = ARGV) # Get a list of CLI plugin activation hooks registry.find_activators(plugin_type: :cli_command).each do |act| next if act.activated? # Decide whether to activate. Several conditions, so split them out for clarity. # Assume no, to start. Each condition may flip it true, which will short-circuit # all following ||= ops. activate_me = false # If the user invoked `inspec help`, `inspec --help`, or only `inspec` # then activate all CLI plugins so they can display their usage message. activate_me ||= ["help", "--help", nil].include?(cli_args.first) # If there is anything in the CLI args with the same name, activate it. # This is the expected usual activation for individual plugins. # `inspec dosomething` => activate the :dosomething hook activate_me ||= cli_args.include?(act.activator_name.to_s) # OK, activate. if activate_me act.activate act.implementation_class.register_with_thor end end end |