Add distant_bin and distant_args to LaunchOpts

pull/96/head
Chip Senkbeil 3 years ago
parent 2ae80950cf
commit 8757b8af44
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -160,6 +160,8 @@ impl Session {
handler,
ssh,
timeout,
distant_bin,
distant_args,
} = opts;
// First, establish a connection to an SSH server
@ -175,8 +177,9 @@ impl Session {
let session = match mode {
Mode::Distant => ssh_session
.into_distant_session(IntoDistantSessionOpts {
binary: distant_bin,
args: distant_args,
timeout,
..Default::default()
})
.await
.to_lua_err()?,

@ -80,11 +80,26 @@ impl<'lua> FromLua<'lua> for ConnectOpts {
#[derive(Default)]
pub struct LaunchOpts<'a> {
/// Host to connect to remotely (e.g. example.com)
pub host: String,
/// Mode to use for communication (ssh or distant server)
pub mode: Mode,
/// Callbacks to be triggered on various authentication events
pub handler: Ssh2AuthHandler<'a>,
/// Miscellaneous ssh configuration options
pub ssh: Ssh2SessionOpts,
/// Maximum time to wait for launch to complete
pub timeout: Duration,
/// Binary representing the distant server on the remote machine
pub distant_bin: String,
/// Additional CLI options to pass to the distant server when starting
pub distant_args: String,
}
impl fmt::Debug for LaunchOpts<'_> {
@ -171,6 +186,20 @@ impl<'lua> FromLua<'lua> for LaunchOpts<'lua> {
let milliseconds: Option<u64> = tbl.get("timeout")?;
Duration::from_millis(milliseconds.unwrap_or(TIMEOUT_MILLIS))
},
distant_bin: {
let distant_bin: Option<String> = tbl.get("distant_bin")?;
distant_bin.unwrap_or_else(|| String::from("distant"))
},
distant_args: {
let value: LuaValue = tbl.get("distant_args")?;
match value {
LuaValue::String(args) => args.to_str()?.to_string(),
x => {
let args: Vec<String> = lua.from_value(x)?;
args.join(" ")
}
}
},
}),
LuaValue::Nil => Err(LuaError::FromLuaConversionError {
from: "Nil",

Loading…
Cancel
Save