Skip to content

Commit 354506e

Browse files
committed
Add a doc comment and example usage.
Signed-off-by: Aalekh Patel <aalekh.gwpeck.7998@icloud.com>
1 parent 3c42183 commit 354506e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/command.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ pub trait OverSsh {
5959
impl OverSsh for std::process::Command {
6060
/// Given a session, convert a std::process::Command into an `openssh::Command`
6161
/// that can be executed over that session.
62+
/// ```no_run
63+
/// use std::process::Command;
64+
/// use openssh::{Session, KnownHosts, OverSsh};
65+
66+
/// let session = Session::connect_mux("me@ssh.example.com", KnownHosts::Strict).await?;
67+
/// let ls =
68+
/// Command::new("ls")
69+
/// .arg("-l")
70+
/// .arg("-a")
71+
/// .arg("-h")
72+
/// .with_session(&session)
73+
/// .output()
74+
/// .await?;
75+
/// assert!(String::from_utf8(ls.stdout).unwrap().contains("total"));
76+
///
77+
///
78+
/// ```
6279
fn with_session<'session>(&self, session: &'session Session) -> Result<Command<'session>, Error> {
6380
let program =
6481
self

0 commit comments

Comments
 (0)