class Pry::Prompt

Prompt represents the Pry prompt, which can be used with Readline-like libraries. It defines a few default prompts (default prompt, simple prompt, etc) and also provides an API for adding and implementing custom prompts.

@example Registering a new Pry prompt

Pry::Prompt.add(
  :ipython,
  'IPython-like prompt', [':', '...:']
) do |_context, _nesting, pry_instance, sep|
  sep == ':' ? "In [#{pry_instance.input_ring.count}]: " : '   ...: '
end

# Produces:
# In [3]: def foo
#    ...:   puts 'foo'
#    ...: end
# => :foo
# In [4]:

@example Manually instantiating the Prompt class

prompt_procs = [
  proc { '#{rand(1)}>" },
  proc { "#{('a'..'z').to_a.sample}*" }
]
prompt = Pry::Prompt.new(
  :random,
  'Random number or letter prompt.',
  prompt_procs
)
prompt.wait_proc.call(...) #=>
prompt.incomplete_proc.call(...)

@since v0.11.0 @api public