Improve RichFormatter's multi-line error formatting #5550
Labels
A-help
Area: documentation, including docs.rs, readme, examples, etc...
C-enhancement
Category: Raise on the bar on expectations
M-breaking-change
Meta: Implementing or merging this will introduce a breaking change.
Please complete the following tasks
Clap Version
4.5.7
Describe your use case
I return multi-line errors in some parsers, which causes minor formatting issues when using
RichFormatter
. For example:Current format:
Desired format:
Describe the solution you'd like
Please note that I'm not very familiar with the clap's code base. Should this feature even be added or not?
A possible solution (but most likely a breaking change) would be to check if the formatted
source
error is multi-line, and if so, add a newline character to ensure proper formatting.Another possible solution would be to make
RichFormatter
configurable.Alternatives, if applicable
I've created a patch for my own use case here. It was very hard to make :)
https://github.com/clap-rs/clap/compare/v4.5.7...mahor1221:clap:patch?expand=1
Additional Context
Here is the location of the issue:
clap/clap_builder/src/error/format.rs
Line 370 in 6c6839a
The text was updated successfully, but these errors were encountered: