Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly pad aliases for option usage
When printing the options of a command, options without aliases are padded so they aligned with options with aliases The size of the padding is calculated by multiplying the max number of aliases for an option by the number 4 (a dash, a letter, a comma and a space?). Options can have aliases of arbitrary length, not just just a dash with a single letter. For example in Rails the `main` option has the [alias](https://github.com/rails/rails/blob/main/railties/lib/rails/generators/app_base.rb#L100)` --master`. Also, the current implementation adds padding only to options without aliases. This results in strange output when callings `bin/rails new -h`: ```console -T, [--skip-test], [--no-skip-test] # Skip test files [--skip-system-test], [--no-skip-system-test] # Skip system test files [--skip-bootsnap], [--no-skip-bootsnap] # Skip bootsnap gem ... [--edge], [--no-edge] # Set up the application with a Gemfile pointing to the main branch on the Rails repository --master, [--main], [--no-main] # Set up the application with Gemfile pointing to Rails repository main branch ``` When printing the usage for options we should look at the actual formatted options. __Before (examples)__ ```console Usage: thor my_counter N [N] Options: -t, [--third=THREE] # The third argument # Default: 3 [--fourth=N] # The fourth argument z, [--simple=N] y, r, [--symbolic=N] ``` __After (examples)__ ```console Usage: thor my_counter N [N] Options: -t, [--third=THREE] # The third argument # Default: 3 [--fourth=N] # The fourth argument z, [--simple=N] y, r, [--symbolic=N] ```
- Loading branch information