Skip to content

Commit

Permalink
imp: allows printing version to any io::Write object
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed May 30, 2016
1 parent 7e2e2cb commit 921f5f7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 921f5f7

Please sign in to comment.