-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "rails routes --expanded" mode #32130
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @georgeclaghorn (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
Good idea Benoit, this will be helpful. It'll be harder to |
@jaredbeck you can still use '-c controller' or '-g pattern'
|
Awesome. I had no idea about either of those, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Can you add a CHANGELOG entry to the railties changelog?
@@ -7,12 +7,14 @@ module Command | |||
class RoutesCommand < Base # :nodoc: | |||
class_option :controller, aliases: "-c", type: :string, desc: "Specifies the controller." | |||
class_option :grep_pattern, aliases: "-g", type: :string, desc: "Specifies grep pattern." | |||
class_option :expanded_format, aliases: "--expanded", type: :string, desc: "Specifies grep pattern." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that desc
should be rewrited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouppps correct
When it's good I can squash. Thanks to all of you for the reviews. 🤙🏻 |
When using rails routes with small terminal or complicated routes it can be very difficult to understand where is the element listed in header. psql had the same issue, that's why they created "expanded mode" you can switch using `\x` or by starting psql with ``` -x --expanded Turn on the expanded table formatting mode. This is equivalent to the \x command. ``` The output is similar to one implemented here for rails routes: db_user-# \du List of roles -[ RECORD 1 ]---------------------------------------------- Role name | super Attributes | Superuser, Create role, Create DB Member of | {} -[ RECORD 2 ]---------------------------------------------- Role name | role Attributes | Superuser, Create role, Create DB, Replication Member of | {}
35d6798
to
c6d928f
Compare
Squashed 🎉 |
Really excited for this feature, thank you so much for your work. 🎆 |
…--expanded` In order to get width of console use `IO::console_size`, See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size Related to rails#32130
- Create `Base` and inherit `Sheet` and `Expanded` in order to - prevent code duplication. - Remove trailing "\n" for components of `Expanded`. - There is no need for `Expanded#header` to return `@buffer` so return `nil` instead. - Change `no_routes` message "No routes were found for this controller" since if use `-g`, it sounds incorrect. - Display `No routes were found for this controller.` if apply `-c`. - Display `No routes were found for this grep pattern.` if apply `-g`. Related to rails#32130
Summary
When using rails routes with small terminal or complicated routes it can be very difficult to understand where a specific element is, especially when using header. psql had the same issue, that's why they created "expanded mode" long time ago that you can
switch using
\x
or by starting psql withThe output is similar to one implemented here for
rails routes
:Here is an output expanded mode (I removed active storage routes):
Other Information