module NewRelicRMQPlugin::CLI

> NewRelic Launcher

Public Instance Methods

run(argv = ARGV) click to toggle source

> Launch the Application

# File lib/newrelic-rmq-plugin/cli.rb, line 38
def run(argv = ARGV)
  # => Parse CLI Configuration
  cli = Options.new
  cli.parse_options(argv)

  # => Parse JSON Config File (If Specified and Exists)
  json_config = Util.parse_json(cli.config[:config_file] || Config.config_file)

  # => Grab the Default Values
  default = Config.options

  # => Merge Configuration (CLI Wins)
  config = [default, json_config, cli.config].compact.reduce(:merge)

  # => Apply Configuration
  Config.setup do |cfg|
    cfg.nr_config_file = config[:nr_config_file]
  end

  # => Load up the NewRelic Configuration
  NewRelic::Plugin::Config.config_file = Config.nr_config_file

  # => Launch the Plugin
  NewRelic::Plugin::Run.setup_and_run
end