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/change_prompt.rb
Kyrylo Silin 3da930f908 prompt: add basic API for adding prompts
Fixes #1836 (Add an API for adding new prompts)
2018-11-04 02:11:15 +08:00

22 lines
574 B
Ruby

class Pry::Command::ChangePrompt < Pry::ClassCommand
match 'change-prompt'
group 'Input and Output'
description 'Change the current prompt.'
command_options argument_required: true
banner <<-BANNER
Usage: change-prompt NAME
Change the current prompt. See list-prompts for a list of available
prompts.
BANNER
def process(prompt)
if Pry::Prompt.all.key?(prompt)
_pry_.prompt = Pry::Prompt.all[prompt][:value]
else
raise Pry::CommandError, "'#{prompt}' isn't a known prompt!"
end
end
Pry::Commands.add_command(self)
end