1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

system is now determined by a proc, Pry.config.system

This commit is contained in:
John Mair 2011-09-17 18:35:17 +12:00
parent d9f3c7852a
commit 66c464bafe
5 changed files with 17 additions and 7 deletions

View file

@ -114,6 +114,11 @@ class Pry
end,
]
DEFAULT_SYSTEM = proc do |cmd|
if !system(cmd)
output.puts "Error: there was a problem executing system command: #{cmd}"
end
end
# As a REPL, we often want to catch any unexpected exceptions that may have
# been raised; however we don't want to go overboard and prevent the user

View file

@ -118,6 +118,10 @@ class Pry
# @return [Proc] The proc that manages ^D presses in the REPL.
# The proc is passed the current eval_string and the current pry instance.
attr_accessor :control_d_handler
# @return [Proc] The proc that runs system commands
# The proc is passed the command string to eval
attr_accessor :system
end
end

View file

@ -11,11 +11,8 @@ class Pry
rescue Errno::ENOENT
output.puts "No such directory: #{dest}"
end
else
if !system(cmd)
output.puts "Error: there was a problem executing system command: #{cmd}"
end
Pry.config.system.call(cmd)
end
end

View file

@ -389,10 +389,13 @@ class Pry
pid = Spoon.spawnp(*editor_invocation.split)
Process.waitpid(pid)
rescue FFI::NotFoundError
run ".#{editor_invocation}"
system(editor_invocation)
end
else
run ".#{editor_invocation}"
# Note we dont want to use Pry.config.system here as that
# may be invoked non-interactively (i.e via Open4), whereas we want to
# ensure the editor is always interactive
system(editor_invocation)
end
end

View file

@ -51,7 +51,7 @@ class Pry
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
delegate_accessors :@config, :input, :output, :commands, :prompt, :print, :exception_handler,
:hooks, :color, :pager, :editor, :memory_size, :input_stack
:hooks, :color, :pager, :editor, :memory_size, :input_stack, :system
end
# Load the rc files given in the `Pry::RC_FILES` array.
@ -186,6 +186,7 @@ class Pry
config.input_stack = []
config.color = true
config.pager = true
config.system = DEFAULT_SYSTEM
config.editor = default_editor_for_platform
config.should_load_rc = true
config.disable_auto_reload = false