mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
parent
335f34bee2
commit
2a2969aee4
2 changed files with 10 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
// Std
|
// Std
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::io::{self, BufWriter, Write};
|
use std::io::Write;
|
||||||
use std::iter::Peekable;
|
use std::iter::Peekable;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
|
@ -1545,13 +1545,12 @@ where
|
||||||
|
|
||||||
fn version_err(&self, use_long: bool) -> ClapError {
|
fn version_err(&self, use_long: bool) -> ClapError {
|
||||||
debugln!("Parser::version_err: ");
|
debugln!("Parser::version_err: ");
|
||||||
let out = io::stdout();
|
let mut buf = vec![];
|
||||||
let mut buf_w = BufWriter::new(out.lock());
|
match self.print_version(&mut buf, use_long) {
|
||||||
match self.print_version(&mut buf_w, use_long) {
|
|
||||||
Err(e) => e,
|
Err(e) => e,
|
||||||
_ => ClapError {
|
_ => ClapError {
|
||||||
cause: String::new(),
|
cause: String::new(),
|
||||||
message: String::new(),
|
message: String::from_utf8(buf).unwrap_or_default(),
|
||||||
kind: ErrorKind::VersionDisplayed,
|
kind: ErrorKind::VersionDisplayed,
|
||||||
info: None,
|
info: None,
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,7 +18,9 @@ fn version_short() {
|
||||||
.try_get_matches_from(vec!["myprog", "-V"]);
|
.try_get_matches_from(vec!["myprog", "-V"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::VersionDisplayed);
|
let err = m.unwrap_err();
|
||||||
|
assert_eq!(err.kind, ErrorKind::VersionDisplayed);
|
||||||
|
assert_eq!(err.message, "test 1.3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -30,7 +32,9 @@ fn version_long() {
|
||||||
.try_get_matches_from(vec!["myprog", "--version"]);
|
.try_get_matches_from(vec!["myprog", "--version"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::VersionDisplayed);
|
let err = m.unwrap_err();
|
||||||
|
assert_eq!(err.kind, ErrorKind::VersionDisplayed);
|
||||||
|
assert_eq!(err.message, "test 1.3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue