class RogueOne::CLI

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/rogue_one/cli.rb, line 9
def exit_on_failure?
  true
end

Public Instance Methods

report(dns_server) click to toggle source
# File lib/rogue_one/cli.rb, line 20
def report(dns_server)
  with_error_handling do
    Ping.pong? dns_server

    custom_list = options["custom_list"]
    default_list = options["default_list"].downcase
    record_type = options["record_type"].upcase
    threshold = options["threshold"]
    verbose = options["verbose"]

    detector = Detector.new(
      custom_list: custom_list,
      default_list: default_list,
      record_type: record_type,
      target: dns_server,
      threshold: threshold,
      verbose: verbose,
    )
    puts JSON.pretty_generate(detector.report)
  end
end
with_error_handling() { || ... } click to toggle source
# File lib/rogue_one/cli.rb, line 43
def with_error_handling
  yield
rescue StandardError => e
  message = { error: e.to_s }
  puts JSON.pretty_generate(message)
end