2014-03-19 09:06:26 -04:00
|
|
|
class Pry::Command::ListPrompts < Pry::ClassCommand
|
|
|
|
match 'list-prompts'
|
2014-05-05 03:49:45 -04:00
|
|
|
group 'Input and Output'
|
|
|
|
description 'List the prompts available for use.'
|
2014-03-19 09:06:26 -04:00
|
|
|
banner <<-BANNER
|
|
|
|
Usage: list-prompts
|
2014-05-05 03:49:45 -04:00
|
|
|
|
|
|
|
List the available prompts. You can use change-prompt to switch between
|
|
|
|
them.
|
2014-03-19 09:06:26 -04:00
|
|
|
BANNER
|
|
|
|
|
|
|
|
def process
|
|
|
|
output.puts heading("Available prompts") + "\n"
|
|
|
|
prompt_map.each do |name, prompt|
|
2017-11-16 11:54:14 -05:00
|
|
|
output.write "Name: #{bold(name)}"
|
2014-03-19 09:06:26 -04:00
|
|
|
output.puts selected_prompt?(prompt) ? selected_text : ""
|
|
|
|
output.puts prompt[:description]
|
|
|
|
output.puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def prompt_map
|
|
|
|
Pry::Prompt::MAP
|
|
|
|
end
|
|
|
|
|
|
|
|
def selected_text
|
2017-11-16 11:54:14 -05:00
|
|
|
red " (selected) "
|
2014-03-19 09:06:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def selected_prompt?(prompt)
|
|
|
|
_pry_.prompt == prompt[:value]
|
|
|
|
end
|
|
|
|
Pry::Commands.add_command(self)
|
|
|
|
end
|