diff --git a/lib/pry/cli.rb b/lib/pry/cli.rb index 66ae3e3e..781c2dbe 100644 --- a/lib/pry/cli.rb +++ b/lib/pry/cli.rb @@ -143,6 +143,10 @@ Copyright (c) 2013 John Mair (banisterfiend) Pry.plugins[plugin_name].disable! end + on :i, "interactive", "Go interactive after execution" do + Pry.config.exit_interactive = true + end + on "no-plugins", "Suppress loading of plugins." do Pry.config.should_load_plugins = false end @@ -200,12 +204,15 @@ end.process_options do |opts| Pry.initial_session_setup context = Pry.binding_for(eval(opts[:context])) else - context = Pry.top_level_binding + context = Pry.toplevel_binding end if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"] full_name = File.expand_path(Pry::CLI.input_args.first) Pry.load_file_through_repl(full_name) + if Pry.config.exit_interactive + Pry.toplevel_binding.pry + end exit end diff --git a/lib/pry/config.rb b/lib/pry/config.rb index 71c877be..e21a2577 100644 --- a/lib/pry/config.rb +++ b/lib/pry/config.rb @@ -69,6 +69,10 @@ class Pry # Pry.config.exception_whitelist = [SystemExit, SignalException] attr_accessor :exception_whitelist + # Send Pry into interactive mode after finishing execution + # @return [Boolean] + attr_accessor :exit_interactive + # @return [Fixnum] The number of lines of context to show before and after # exceptions, etc. # @example