use super::super::address::RemoteFile;
use std::process::{Command, Stdio};
pub(super) fn sftp_subsystem(file: &RemoteFile) -> Command {
let mut command = Command::new("ssh");
command
.arg("-s")
.arg("-T")
.arg("-a")
.arg("-x")
.arg("-o")
.arg("BatchMode=yes")
.arg("-o")
.arg("StrictHostKeyChecking=yes")
.arg("-o")
.arg("ClearAllForwardings=yes")
.arg("-o")
.arg("ControlMaster=no")
.arg("-o")
.arg("ControlPath=none")
.arg("-o")
.arg("RemoteCommand=none")
.arg("-o")
.arg("ForkAfterAuthentication=no")
.arg("-o")
.arg("ControlPersist=no");
if let Some(user) = file.user() {
command.arg("-l").arg(user);
}
if let Some(port) = file.port() {
command.arg("-p").arg(port.get().to_string());
}
command.arg("--").arg(file.host()).arg("sftp");
command
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
command
}