diff --git a/lib/pry/config/convenience.rb b/lib/pry/config/convenience.rb index b814c773..9d9273df 100644 --- a/lib/pry/config/convenience.rb +++ b/lib/pry/config/convenience.rb @@ -3,7 +3,6 @@ module Pry::Config::Convenience :input, :output, :commands, - :prompt, :print, :exception_handler, :quiet?, diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 6d5ebd49..c3cb2ada 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -20,6 +20,14 @@ class Pry extend Pry::Config::Convenience config_shortcut *Pry::Config.shortcuts + + def prompt=(value) + config.prompt = value + end + + def prompt + config.prompt + end end def self.main diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index a03441f6..138cd403 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -69,6 +69,7 @@ class Pry @backtrace = options[:backtrace] || caller @config = Pry::Config.new @config.merge!(options) + push_prompt(config.prompt) @input_array = Pry::HistoryArray.new config.memory_size @output_array = Pry::HistoryArray.new config.memory_size @custom_completions = config.command_completer @@ -78,6 +79,26 @@ class Pry exec_hook(:when_started, options[:target], options, self) end + # The current prompt. + # This is the prompt at the top of the prompt stack. + # + # @example + # self.prompt = Pry::SIMPLE_PROMPT + # self.prompt # => Pry::SIMPLE_PROMPT + # + # @return [Array] Current prompt. + def prompt + prompt_stack.last + end + + def prompt=(new_prompt) + if prompt_stack.empty? + push_prompt new_prompt + else + prompt_stack[-1] = new_prompt + end + end + # Initialize this instance by pushing its initial context into the binding # stack. If no target is given, start at the top level. def push_initial_binding(target=nil)