1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/lib/pry/commands/list_inspectors.rb
r-obert 7c1a652c6b
Deprecate Pry::Command#text. Please use black(), white(), etc directly (#1701)
instead (as you would with helper functions from BaseHelpers and
CommandHelpers)
2017-11-16 17:54:14 +01:00

35 lines
871 B
Ruby

class Pry::Command::ListInspectors < Pry::ClassCommand
match 'list-inspectors'
group 'Input and Output'
description 'List the inspector procs available for use.'
banner <<-BANNER
Usage: list-inspectors
List the inspector procs available to print return values. You can use
change-inspector to switch between them.
BANNER
def process
output.puts heading("Available inspectors") + "\n"
inspector_map.each do |name, inspector|
output.write "Name: #{bold(name)}"
output.puts selected_inspector?(inspector) ? selected_text : ""
output.puts inspector[:description]
output.puts
end
end
private
def inspector_map
Pry::Inspector::MAP
end
def selected_text
red " (selected) "
end
def selected_inspector?(inspector)
_pry_.print == inspector[:value]
end
Pry::Commands.add_command(self)
end