Skip to content

Conversation

@hmaddocks
Copy link

I am porting a Rails app to Hanami that has some deeep routes with long controller names. This is a sample of the output from the hanami routes command. The columns of the output is being squashed together.

GET     /admin/practitioners/:practitioner_id/appointment_types/:id/editappointment_types.edit        as :edit_admin_practitioner_appointment_type
PATCH   /admin/practitioners/:practitioner_id/appointment_types/:idappointment_types.update      as :admin_practitioner_appointment_type
DELETE  /admin/practitioners/:practitioner_id/appointment_types/:idappointment_types.destroy     as :admin_practitioner_appointment_type
POST    /admin/practitioners/:practitioner_id/schedulesschedules.create              as :admin_practitioner_schedules
PATCH   /admin/practitioners/:practitioner_id/schedules/:idschedules.update              as :admin_practitioner_schedule

This is after this fix. The column alignment is being maintained.

GET     /admin/practitioners/:practitioner_id/appointment_types/:id/edit                             appointment_types.edit                 as :edit_admin_practitioner_appointment_type
PATCH   /admin/practitioners/:practitioner_id/appointment_types/:id                                  appointment_types.update               as :admin_practitioner_appointment_type
DELETE  /admin/practitioners/:practitioner_id/appointment_types/:id                                  appointment_types.destroy              as :admin_practitioner_appointment_type
POST    /admin/practitioners/:practitioner_id/schedules                                              schedules.create                       as :admin_practitioner_schedules
PATCH   /admin/practitioners/:practitioner_id/schedules/:id                                          schedules.update                       as :admin_practitioner_schedule

The code ieterates the routes twice. Once to find the max column width and second to print out the routes. This might be slow for an application with a lot of routes.
The new code also maintains a 5 character spacing between columns.

Make it handle very long paths better
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant