class Inspec::Shell

def configure_pry # rubocop:disable Metrics/AbcSize

rubocop:disable Metrics/AbcSize
def configure_pry # rubocop:disable Metrics/AbcSize
  # Delete any before_session, before_eval, and after_eval hooks so we can
  # replace them with our own. Pry 0.10 used to have a single method to clear
  # all hooks, but this was removed in Pry 0.11.
  [:before_session, :before_eval, :after_eval].each do |event|
    Pry.hooks.get_hooks(event).keys.map { |hook| Pry.hooks.delete_hook(event, hook) }
  end
  that = self
  # Add the help command
  Pry::Commands.block_command 'help', 'Show examples' do |resource|
    that.help(resource)
  end
  # configure pry shell prompt
  Pry.config.prompt_name = 'inspec'
  Pry.prompt = [proc { "#{readline_ignore("\e[1m\e[32m")}#{Pry.config.prompt_name}> #{readline_ignore("\e[0m")}" }]
  # Add a help menu as the default intro
  Pry.hooks.add_hook(:before_session, 'inspec_intro') do
    intro
    print_target_info
  end
  # Track the rules currently registered and what their merge count is.
  Pry.hooks.add_hook(:before_eval, 'inspec_before_eval') do
    @runner.reset
  end
  # After pry has evaluated a commanding within the binding context of a
  # test file, register all the rules it discovered.
  Pry.hooks.add_hook(:after_eval, 'inspec_after_eval') do
    @runner.load
    @runner.run_tests if !@runner.all_rules.empty?
  end
  # Don't print out control class inspection when the user uses DSL methods.
  # Instead produce a result of evaluating their control.
  Pry.config.print = proc do |_output_, value, pry|
    next if !@runner.all_rules.empty?
    pry.pager.open do |pager|
      pager.print pry.config.output_prefix
      Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
    end
  end
end