+ // We need the opts_present check because the driver will send us Matches
+ // with only stable options if no unstable options are used. Since output is
+ // unstable, it will not be present. We have to use opts_present not
+ // opt_present because the latter will panic.
+ let output = if matches.opts_present(&["output".to_owned()]) {
+ match matches.opt_str("output").as_ref().map(|s| &s[..]) {
+ Some("tty") => ErrorOutputType::Tty(color),
+ Some("json") => ErrorOutputType::Json,
+
+ None => ErrorOutputType::default(),
+
+ Some(arg) => {
+ early_error(ErrorOutputType::default(), &format!("argument for --output must be tty or \
+ json (instead was `{}`)",
+ arg))
+ }
+ }
+ } else {
+ ErrorOutputType::default()
+ };
+