Add summary_width
and summary_indent
to OptionParser
in Crystal
#15326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
This pull request introduces enhancements to the
OptionParser
in CrystalThese features are similar to the
summary_width
andsummary_indent
found in Ruby'sOptionParser
.See #14153
Motivation
Currently, the indentation settings in
OptionParser
are hard-coded, which can limit the flexibility and fun of creating command line tools. The default width is set to 32, the same as the Ruby default, which is too wide for many use cases. Being able to customize these settings would be beneficial for a variety of command line utilities.Implementation
With the help of ChatGPT and Gemni, I looked into how these features are provided in major programming languages, but the naming and APIs vary across languages and libraries, and best practices are unclear. So I simply went for the Ruby approach.
Actually, I don't really care about this approach or implementation. I hate the fact that you can't specify indentation in the standard library, so I submitted it because I thought no one would touch it unless I submitted a pull request.
I'm willing to close this if someone provides a better pull request.
Thank you.