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:
parent
5177913c91
commit
52f7260090
6 changed files with 7 additions and 13 deletions
|
@ -177,7 +177,6 @@ require 'pry/history'
|
||||||
require 'pry/command'
|
require 'pry/command'
|
||||||
require 'pry/command_set'
|
require 'pry/command_set'
|
||||||
require 'pry/commands'
|
require 'pry/commands'
|
||||||
require 'pry/custom_completions'
|
|
||||||
require 'pry/completion'
|
require 'pry/completion'
|
||||||
require 'pry/plugins'
|
require 'pry/plugins'
|
||||||
require 'pry/core_extensions'
|
require 'pry/core_extensions'
|
||||||
|
|
|
@ -12,10 +12,10 @@ class Pry
|
||||||
case _pry_.prompt
|
case _pry_.prompt
|
||||||
when Pry::SHELL_PROMPT
|
when Pry::SHELL_PROMPT
|
||||||
_pry_.pop_prompt
|
_pry_.pop_prompt
|
||||||
_pry_.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
|
_pry_.custom_completions = _pry_.config.file_completer
|
||||||
else
|
else
|
||||||
_pry_.push_prompt Pry::SHELL_PROMPT
|
_pry_.push_prompt Pry::SHELL_PROMPT
|
||||||
_pry_.custom_completions = Pry::FILE_COMPLETIONS
|
_pry_.custom_completions = _pry_.config.command_completer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,8 @@ class Pry::Config::Default < Pry::Config
|
||||||
:control_d_handler => proc { Pry::DEFAULT_CONTROL_D_HANDLER },
|
:control_d_handler => proc { Pry::DEFAULT_CONTROL_D_HANDLER },
|
||||||
:memory_size => proc { 100 },
|
:memory_size => proc { 100 },
|
||||||
:extra_sticky_locals => proc { {} },
|
:extra_sticky_locals => proc { {} },
|
||||||
|
:command_completer => proc { Pry.commands.commands.keys },
|
||||||
|
:file_completer => proc { Dir["."] },
|
||||||
:completer => proc {
|
:completer => proc {
|
||||||
if defined?(Bond) && Readline::VERSION !~ /editline/i
|
if defined?(Bond) && Readline::VERSION !~ /editline/i
|
||||||
Pry::BondCompleter.start
|
Pry::BondCompleter.start
|
||||||
|
|
|
@ -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
|
|
|
@ -248,7 +248,6 @@ Readline version #{ver} detected - will not auto_resize! correctly.
|
||||||
# Set all the configurable options back to their default values
|
# Set all the configurable options back to their default values
|
||||||
def self.reset_defaults
|
def self.reset_defaults
|
||||||
@initial_session = true
|
@initial_session = true
|
||||||
self.custom_completions = DEFAULT_CUSTOM_COMPLETIONS
|
|
||||||
self.cli = false
|
self.cli = false
|
||||||
self.current_line = 1
|
self.current_line = 1
|
||||||
self.line_buffer = [""]
|
self.line_buffer = [""]
|
||||||
|
|
|
@ -25,6 +25,7 @@ require "pry/indent"
|
||||||
|
|
||||||
class Pry
|
class Pry
|
||||||
attr_accessor :binding_stack
|
attr_accessor :binding_stack
|
||||||
|
attr_accessor :custom_completions
|
||||||
attr_accessor :eval_string
|
attr_accessor :eval_string
|
||||||
attr_accessor :backtrace
|
attr_accessor :backtrace
|
||||||
attr_accessor :suppress_output
|
attr_accessor :suppress_output
|
||||||
|
@ -72,11 +73,10 @@ class Pry
|
||||||
@config.merge!(options)
|
@config.merge!(options)
|
||||||
@input_array = Pry::HistoryArray.new config.memory_size
|
@input_array = Pry::HistoryArray.new config.memory_size
|
||||||
@output_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])
|
push_initial_binding(options[:target])
|
||||||
set_last_result nil
|
set_last_result nil
|
||||||
@input_array << nil # add empty input so _in_ and _out_ match
|
@input_array << nil
|
||||||
# yield the binding_stack to the hook for modification
|
|
||||||
exec_hook(:when_started, options[:target], options, self)
|
exec_hook(:when_started, options[:target], options, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue