rails icon indicating copy to clipboard operation
rails copied to clipboard

Custom route formatters

Open phendrick opened this issue 2 years ago • 2 comments

Summary

To allow for custom route renderers (to add colour, emoji, or additional route filtering) via the rails routes command, this PR adds formatter registration to the ConsoleFormatters module.

The Sheet and Expanded formatters are now SheetFormatter and ExpandedFormatter and are both registered formatters.

Other Information

I've written a small demo gem which you can see here which registers an emoji formatter and renders this output when running rails routes --formatter emoji:

Image of Emoji routes formatter output

Generating the output of the routes command via a custom formatter means we can add additional flags, like --compact which strips out certain routes like those that belong to action_mailbox, turbo etc)

phendrick avatar Jun 11 '22 11:06 phendrick

Very related: #45241, it may be worth trying to work together on this one

skipkayhil avatar Jun 11 '22 19:06 skipkayhil

Very related: #45241, it may be worth trying to work together on this one

Thanks @skipkayhil I'll follow up on that PR 👍

phendrick avatar Jun 11 '22 19:06 phendrick