use crate::ssh::ssh_config::parser::helpers::parse_yes_no;
use crate::ssh::ssh_config::security::validate_executable_string;
use crate::ssh::ssh_config::types::SshHostConfig;
use anyhow::Result;
pub(super) fn parse_proxy_option(
host: &mut SshHostConfig,
keyword: &str,
args: &[String],
line_number: usize,
) -> Result<()> {
match keyword {
"proxyjump" => {
if args.is_empty() {
anyhow::bail!("ProxyJump requires a value at line {line_number}");
}
host.proxy_jump = Some(args.join(" "));
}
"proxycommand" => {
if args.is_empty() {
anyhow::bail!("ProxyCommand requires a value at line {line_number}");
}
let command = args.join(" ");
validate_executable_string(&command, "ProxyCommand", line_number)?;
host.proxy_command = Some(command);
}
"proxyusefdpass" => {
if args.is_empty() {
anyhow::bail!("ProxyUseFdpass requires a value at line {line_number}");
}
let value = parse_yes_no(&args[0], line_number)?;
host.proxy_use_fdpass = Some(value);
}
_ => unreachable!("Unexpected keyword in parse_proxy_option: {}", keyword),
}
Ok(())
}