openssh-rust / openssh

Scriptable SSH through OpenSSH in Rust
Apache License 2.0
230 stars 34 forks source link

arc_shell #149

Open kanpov opened 1 month ago

kanpov commented 1 month ago

The same as arc_command, but for shell.

I did this very easily via an extension trait, but it should be available out-of-the-box imo considering arc_command and arc_raw_command are there:

trait ArcShellExt {
    fn arc_shell<S: AsRef<str>>(self: Arc<Self>, command: S) -> OwningCommand<Arc<Self>>;
}

impl ArcShellExt for Session {
    fn arc_shell<S: AsRef<str>>(self: Arc<Self>, command: S) -> OwningCommand<Arc<Self>> {
        let mut cmd = self.arc_command("sh");
        cmd.arg("-c").arg(command.as_ref());
        cmd
    }
}
NobodyXu commented 1 month ago

That's neat!

I would welcome PR/contribution for that API!