use shared::{errors::Error, names}; use std::path::Path; use crate::commands::utils::{site_string, PrintOptions}; pub(crate) fn remove(path: &Path, url: &String, separator: &String) -> Result<(), Error> { let names_file = names::read_names_file(path)?; let mut names = names::load_names(names_file)?; names.retain(|site| { if &site.url == url { println!( "removing {} from names.json", site_string(site, PrintOptions::All, separator) ); } &site.url != url }); let json = serde_json::to_string(&names).unwrap(); std::fs::write(path, json).unwrap(); Ok(()) }