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

Completion for show-source/show-doc/?/$ Array#<tab>

This commit is contained in:
Conrad Irwin 2012-11-08 01:18:15 -08:00
parent 5246700e2b
commit 7547b8ca16
2 changed files with 22 additions and 0 deletions

View file

@ -234,6 +234,12 @@ class Pry
run action, *args
end
c.class_eval do
define_method(:complete) do |input|
cmd.new(context).complete(input)
end
end
c.group "Aliases"
c

View file

@ -127,6 +127,22 @@ class Pry
retry
end
end
def complete(input)
if input =~ /([^ ]*)#([a-z0-9_]*)\z/
prefix, search = [$1, $2]
methods = begin
Pry::Method.all_from_class(binding.eval(prefix))
rescue RescuableException => e
return super
end
methods.map do |method|
[prefix, method.name].join('#') if method.name.start_with?(search)
end.compact
else
super
end
end
end
end
end