mirror of
https://github.com/pry/pry-rails.git
synced 2022-11-09 12:36:03 -05:00
Show-routes command can grep displayed routes.
This commit is contained in:
parent
8537ce1de9
commit
9f4a7da49b
1 changed files with 11 additions and 7 deletions
|
@ -26,14 +26,18 @@ module PryRails
|
|||
|
||||
Commands = Pry::CommandSet.new do
|
||||
create_command "show-routes", "Print out all defined routes in match order, with names." do
|
||||
def process
|
||||
all_routes = Rails.application.routes.routes
|
||||
require 'rails/application/route_inspector'
|
||||
inspector = Rails::Application::RouteInspector.new
|
||||
output.puts inspector.format(all_routes).join "\n"
|
||||
end
|
||||
def options(opt)
|
||||
opt.on :G, "grep", "Filter output by regular expression", :argument => true
|
||||
end
|
||||
|
||||
def process
|
||||
all_routes = Rails.application.routes.routes
|
||||
require 'rails/application/route_inspector'
|
||||
inspector = Rails::Application::RouteInspector.new
|
||||
output.puts inspector.format(all_routes).grep(Regexp.new(opts[:G] || ".")).join "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Pry.commands.import PryRails::Commands
|
||||
Pry.commands.import PryRails::Commands
|
||||
|
|
Loading…
Add table
Reference in a new issue