Skip to content

Commit

Permalink
Addressed lint and fmt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tnguye20 committed Apr 3, 2024
1 parent 32612f0 commit f2daf4d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ impl fmt::Display for HostnameGroup {
} else {
""
};
write!(f, "{}{}\n{}\n", self.name, disabled, padded_hostnames.join("\n"))
write!(
f,
"{}{}\n{}\n",
self.name,
disabled,
padded_hostnames.join("\n")
)
}
}

Expand Down Expand Up @@ -182,7 +188,5 @@ pub fn overwrite_config_file(hostgroups: &HostnameGroups) -> Result<(), Box<dyn
}

pub fn split_args(args: &str) -> Vec<String> {
args.split(',')
.map(|x| x.to_lowercase())
.collect()
args.split(',').map(|x| x.to_lowercase()).collect()
}
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ fn main() {
for group in groups.iter_mut() {
if group.name.to_lowercase() == toggle_group.to_lowercase() {
group.disabled = Some(!group.disabled.unwrap_or(false));
println!("Toggled group: {}. Disabled: {}", group.name, group.disabled.unwrap_or(false));
println!(
"Toggled group: {}. Disabled: {}",
group.name,
group.disabled.unwrap_or(false)
);
}
}
}
Expand All @@ -106,10 +110,7 @@ fn main() {
if !args.group.is_empty() && !args.add.is_empty() {
match read_hostname_groups_config() {
Ok(mut groups) => {
let new_hostnames = split_args(
&args.add
.trim()
)
let new_hostnames = split_args(args.add.trim())
.into_iter()
// .replace(' ', "")
.filter(|hostname| hostname.contains('.'))
Expand Down

0 comments on commit f2daf4d

Please sign in to comment.