feat: ssh.rs
This commit is contained in:
@@ -45,11 +45,9 @@ impl SshConfig {
|
||||
for (k, v) in &self.profiles {
|
||||
if k == profile {
|
||||
found.push((k, v));
|
||||
} else {
|
||||
if let Some(alias) = &v.alias {
|
||||
if alias.contains(&profile.to_string()) {
|
||||
found.push((k, v));
|
||||
}
|
||||
} else if let Some(alias) = &v.alias {
|
||||
if alias.contains(&profile.to_string()) {
|
||||
found.push((k, v));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,13 +77,10 @@ fn main() -> XResult<()> {
|
||||
}
|
||||
}
|
||||
for (profile_id, profile) in &ssh_rs_config.profiles {
|
||||
let mut features = vec![];
|
||||
if let Some(true) = profile.forward_agent {
|
||||
features.push("forward_agent");
|
||||
}
|
||||
if let Some(true) = profile.proxy {
|
||||
features.push("proxy");
|
||||
}
|
||||
let features = make_features(
|
||||
profile.forward_agent.unwrap_or(false),
|
||||
profile.proxy.unwrap_or(false),
|
||||
);
|
||||
println!(
|
||||
"- {} : {}{} {}{}{} # {}{}",
|
||||
pad(profile_id, max_profile_id_len),
|
||||
@@ -106,21 +101,18 @@ fn main() -> XResult<()> {
|
||||
},
|
||||
util_term::END,
|
||||
profile.comment.clone().unwrap_or_else(|| "-".to_string()),
|
||||
if features.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
iff!(
|
||||
features.is_empty(),
|
||||
"".to_string(),
|
||||
format!(" ;[{}]", features.join(", "))
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
let mut features = vec![];
|
||||
if let Some(true) = ssh_rs_config.default_forward_agent {
|
||||
features.push("forward_agent");
|
||||
}
|
||||
if let Some(true) = ssh_rs_config.default_proxy {
|
||||
features.push("proxy");
|
||||
}
|
||||
let features = make_features(
|
||||
ssh_rs_config.default_forward_agent.unwrap_or(false),
|
||||
ssh_rs_config.default_proxy.unwrap_or(false),
|
||||
);
|
||||
if !features.is_empty() {
|
||||
println!();
|
||||
information!("Global default features: [{}]", features.join(", "));
|
||||
@@ -205,6 +197,17 @@ fn pad(str: &str, width: usize) -> String {
|
||||
format!("{}{}", str, " ".repeat(width - str.len()))
|
||||
}
|
||||
|
||||
fn make_features(forward_agent: bool, proxy: bool) -> Vec<String> {
|
||||
let mut features = vec![];
|
||||
if forward_agent {
|
||||
features.push("forward_agent".to_string());
|
||||
}
|
||||
if proxy {
|
||||
features.push("proxy".to_string());
|
||||
}
|
||||
features
|
||||
}
|
||||
|
||||
fn parse_username_and_host(username_and_host: &str) -> XResult<(Option<String>, String)> {
|
||||
if username_and_host.is_empty() {
|
||||
return simple_error!("Empty username@host");
|
||||
|
||||
Reference in New Issue
Block a user