Struct clap::error::Error [−][src]
Expand description
Command Line Argument Parser Error
See Command::error to create an error.
Fields
kind: ErrorKindReplaced with Error::kind()
Deprecated, replaced with Error::kind()
info: Vec<String>Replaced with Error::context()
Deprecated, replaced with Error::context()
Implementations
Create an unformatted error
This is for you need to pass the error up to
a place that has access to the Command at which point you can call Error::format.
Prefer Command::error for generating errors.
Format the existing message with the Command’s context
Additional information to further qualify the error
Should the message be written to stdout or not?
Prints the error and exits.
Depending on the error kind, this either prints to stderr and exits with a status of 2
or prints to stdout and exits with a status of 0.
Prints formatted and colored error to stdout or stderr according to its error kind
Example
use clap::Command;
match Command::new("Command").try_get_matches() {
Ok(matches) => {
// do_something
},
Err(err) => {
err.print().expect("Error writing Error");
// do_something
},
};