finish remove command support

master
Aleš Katona 2 years ago
parent 46789afafb
commit 01b179e93b
Signed by: almindor
GPG Key ID: 2F773149BF38B48F

@ -23,6 +23,9 @@ fn main() {
};
match args.command {
Commands::Cd { member } => {
todo!();
}
Commands::Checkout {
reference,
projects,
@ -30,6 +33,9 @@ fn main() {
vcs.checkout_ref(&reference, projects)
.expect("Error setting branch on projects");
}
Commands::Clone { url } => {
todo!();
}
Commands::Profile(ProfileCommand::Save { profile }) => {
vcs.save_profile(&profile)
.expect("Error saving vcs profile");

@ -240,7 +240,26 @@ impl Vcs {
.as_table()
.ok_or_else(|| Error::cargo_error("Cargo_vcs.toml is not a yaml table"))?
.to_owned();
// TODO
if let Some(vcs_section) = vcs_main.get_mut("vcs") {
if let Some(vcs) = vcs_section.as_table_mut() {
if vcs.remove(profile_name).is_none() {
return Err(Error::project_error("Profile not found in toml file"));
}
} else {
return Err(Error::project_error("VCS subsection not a table"));
}
} else {
return Err(Error::project_error("VCS subsection missing in toml file"));
}
let new_contents = toml::to_string(&vcs_main)?;
fs::write(vcs_path, new_contents)?;
// remove from memory list too
self.profiles.retain(|p| p != profile_name);
println!("Profile {} removed", profile_name.with(PROFILE_COLOR),);
Ok(())
}

@ -15,6 +15,15 @@ pub struct Cli {
#[derive(Debug, Parser)]
pub enum Commands {
/// Change directory into a specific member folder
Cd {
/// Workspace member name to change directory to
member: String,
},
Clone {
/// Url to clone workspace from (e.g. ssh)
url: String,
},
/// Show workspace status
Status {
/// Show verbose status information

Loading…
Cancel
Save