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

add Pry.config.file_completer, Pry.config.command_completer

This commit is contained in:
Robert Gleeson 2014-01-20 09:08:38 +01:00
parent 5177913c91
commit 52f7260090
6 changed files with 7 additions and 13 deletions

View file

@ -177,7 +177,6 @@ require 'pry/history'
require 'pry/command'
require 'pry/command_set'
require 'pry/commands'
require 'pry/custom_completions'
require 'pry/completion'
require 'pry/plugins'
require 'pry/core_extensions'

View file

@ -12,10 +12,10 @@ class Pry
case _pry_.prompt
when Pry::SHELL_PROMPT
_pry_.pop_prompt
_pry_.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
_pry_.custom_completions = _pry_.config.file_completer
else
_pry_.push_prompt Pry::SHELL_PROMPT
_pry_.custom_completions = Pry::FILE_COMPLETIONS
_pry_.custom_completions = _pry_.config.command_completer
end
end
end

View file

@ -31,6 +31,8 @@ class Pry::Config::Default < Pry::Config
:control_d_handler => proc { Pry::DEFAULT_CONTROL_D_HANDLER },
:memory_size => proc { 100 },
:extra_sticky_locals => proc { {} },
:command_completer => proc { Pry.commands.commands.keys },
:file_completer => proc { Dir["."] },
:completer => proc {
if defined?(Bond) && Readline::VERSION !~ /editline/i
Pry::BondCompleter.start

View file

@ -1,6 +0,0 @@
class Pry
# This proc will be instance_eval's against the active Pry instance
DEFAULT_CUSTOM_COMPLETIONS = proc { commands.commands.keys }
FILE_COMPLETIONS = proc { commands.commands.keys + Dir.entries('.') }
end

View file

@ -248,7 +248,6 @@ Readline version #{ver} detected - will not auto_resize! correctly.
# Set all the configurable options back to their default values
def self.reset_defaults
@initial_session = true
self.custom_completions = DEFAULT_CUSTOM_COMPLETIONS
self.cli = false
self.current_line = 1
self.line_buffer = [""]

View file

@ -25,6 +25,7 @@ require "pry/indent"
class Pry
attr_accessor :binding_stack
attr_accessor :custom_completions
attr_accessor :eval_string
attr_accessor :backtrace
attr_accessor :suppress_output
@ -72,11 +73,10 @@ class Pry
@config.merge!(options)
@input_array = Pry::HistoryArray.new config.memory_size
@output_array = Pry::HistoryArray.new config.memory_size
@custom_completions = config.command_completer
push_initial_binding(options[:target])
set_last_result nil
@input_array << nil # add empty input so _in_ and _out_ match
# yield the binding_stack to the hook for modification
@input_array << nil
exec_hook(:when_started, options[:target], options, self)
end