$: cargo run -- --scheme asdf:ghjk
error: invalid value 'asdf:ghjk' for '--scheme <TIME-TIME | DEGREE:DEGREE>': as time ranges:
- invalid format
as elevation range:
- invalid float literal (asdf)
- invalid float literal (ghjk)
For more information, try '--help'.
Desired format:
$: cargo run -- --scheme asdf:ghjk
error: invalid value 'asdf:asdf' for '--scheme <TIME-TIME | DEGREE:DEGREE>': # a new line is added here
as time ranges:
- invalid format
as elevation range:
- invalid float literal (asdf)
- invalid float literal (ghjk)
For more information, try '--help'.
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.
This is a tough situation because it happens to be a problem in your case due to the lack of alignment but in other cases it can be neutral or better the existing way.
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: https://github.com/clap-rs/clap/blob/6c6839a454c2cbfc3007e6a2b2a55dd64685771e/clap_builder/src/error/format.rs#L370