mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
show-source/show-doc: temporaily adding complete() method to both commands
Until we find a better home for it, the code for the complete() method is exactly the same in each case so we should come up with a way for show-source/show-doc to share it.
This commit is contained in:
parent
d19aef516e
commit
9e7287a18f
4 changed files with 34 additions and 15 deletions
|
@ -130,6 +130,22 @@ class Pry
|
||||||
def use_line_numbers?
|
def use_line_numbers?
|
||||||
opts.present?(:b) || opts.present?(:l)
|
opts.present?(:b) || opts.present?(:l)
|
||||||
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
|
||||||
Pry::Commands.alias_command "?", "show-doc"
|
Pry::Commands.alias_command "?", "show-doc"
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,6 +111,22 @@ class Pry
|
||||||
def use_line_numbers?
|
def use_line_numbers?
|
||||||
opts.present?(:b) || opts.present?(:l)
|
opts.present?(:b) || opts.present?(:l)
|
||||||
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
|
||||||
|
|
||||||
Pry::Commands.alias_command "show-method", "show-source"
|
Pry::Commands.alias_command "show-method", "show-source"
|
||||||
|
|
|
@ -126,21 +126,6 @@ class Pry
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,3 +23,5 @@ gist:
|
||||||
commands (e.g show-source)\n* files (e.g alpha.rb)\n\nExplicit flags (do these
|
commands (e.g show-source)\n* files (e.g alpha.rb)\n\nExplicit flags (do these
|
||||||
need their own syntax to avoid flags?)\n-i input expressions\n-o output expressions\n--hist
|
need their own syntax to avoid flags?)\n-i input expressions\n-o output expressions\n--hist
|
||||||
history\n\n"
|
history\n\n"
|
||||||
|
show-source:
|
||||||
|
- it displays 'Other options' at top of help output when u do help show-source *BUG*
|
||||||
|
|
Loading…
Reference in a new issue