Module: Pry::InputCompleter

Defined in:
lib/collins_shell/console.rb

Overview

We kill the built in completion so we can tell users what things are available

Class Method Summary collapse

Class Method Details

.build_completion_proc(target, commands = [""], cmplns = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/collins_shell/console.rb', line 11

def build_completion_proc(target, commands=[""], cmplns = nil)
  if cmplns.is_a?(Array) then # Work around for breakage between pry 0.9.9.6 and 0.9.12
    commands = cmplns
  end
  proc do |input|
    commands.map do |cmd|
      cmd_s = cmd.to_s
      if cmd_s.include?(":wtf") then
        "wtf?"
      else
        cmd_s
      end
    end.select{|s| s.start_with?(input)}.uniq # commands.map
  end # proc do
end