mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
imp: allows printing version to any io::Write object
This commit is contained in:
parent
cda27469cd
commit
a7401dc6a1
1 changed files with 16 additions and 0 deletions
|
@ -796,6 +796,22 @@ impl<'a, 'b> App<'a, 'b> {
|
|||
Help::write_app_help(w, &self)
|
||||
}
|
||||
|
||||
/// Writes the version message to the user to a [`io::Write`] object
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use clap::App;
|
||||
/// use std::io;
|
||||
/// let mut app = App::new("myprog");
|
||||
/// let mut out = io::stdout();
|
||||
/// app.write_vesrion(&mut out).ok().expect("failed to write to stdout");
|
||||
/// ```
|
||||
/// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
|
||||
pub fn write_version<W: Write>(&self, w: &mut W) -> ClapResult<()> {
|
||||
self.p.write_version(w).map_err(From::from)
|
||||
}
|
||||
|
||||
/// Starts the parsing process, upon a failed parse an error will be displayed to the user and
|
||||
/// the process with exit with the appropriate error code. By default this method gets all user
|
||||
/// provided arguments from [`env::args_os`] in order to allow for invalid UTF-8 code points,
|
||||
|
|
Loading…
Reference in a new issue