How to change format of error output #4595
-
By default, clap will output something like e.g. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
You can call clap where it returns the error, instead of directly exiting (the method depends on whether you are using Builder or Derive). You can then If you want formatted text in your error, we don't support that yet (see #3108) so you would instead get the error, directly format and print it, and then exit on your own (or apply a no-op formatter and call |
Beta Was this translation helpful? Give feedback.
-
The reason I asked this in the past was because I use let cli = ClapConfig::parse(); where let cli = ClapConfig::try_parse().context("Failed to parse CLI arguments")?; The help message ( |
Beta Was this translation helpful? Give feedback.
You can call clap where it returns the error, instead of directly exiting (the method depends on whether you are using Builder or Derive). You can then
apply
a customErrorFormatter
and then callexit
.If you want formatted text in your error, we don't support that yet (see #3108) so you would instead get the error, directly format and print it, and then exit on your own (or apply a no-op formatter and call
exit
).