diff --git a/Cargo.lock b/Cargo.lock index 6ffe814..bac5b54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,7 +180,7 @@ checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "moshy" -version = "0.1.1" +version = "0.1.2" dependencies = [ "clap", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index 35a5ddd..90b4295 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "moshy" -version = "0.1.1" +version = "0.1.2" edition = "2024" [dependencies] diff --git a/src/main.rs b/src/main.rs index 4cbcaf1..8ba7e92 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,9 +84,23 @@ fn main() { if let Some(list_matches) = matches.subcommand_matches("list") { let sections: Vec = conf .sections() - .filter_map(|s| s.map(|x| x.to_string())) + .filter_map(|s| s) + .filter(|s| *s != "DEFAULT") + .map(|s| s.to_string()) .collect(); - println!("{}", sections.join("\n")); + if list_matches.is_present("verbose") { + for section in §ions { + println!("[{}]", section); + if let Some(sec) = conf.section(Some(section)) { + for (k, v) in sec.iter() { + println!("{} = {}", k, v); + } + } + println!(); + } + } else { + println!("{}", sections.join("\n")); + } process::exit(0); } @@ -174,7 +188,9 @@ fn parse_hostname(hostname_argument: &str, conf: &Ini) -> HostSetup { let sections: Vec = conf .sections() - .filter_map(|s| s.map(|x| x.to_string())) + .filter_map(|s| s) + .filter(|s| *s != "DEFAULT") + .map(|s| s.to_string()) .collect(); debug!("Config sections: {:?}", sections);