|
|
@ -146,7 +146,26 @@ impl Vcs {
|
|
|
|
min_msrv
|
|
|
|
min_msrv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn save_profile(&self, profile_name: &str) -> Result<(), Error> {
|
|
|
|
pub fn list_profiles(&self) -> Result<(), Error> {
|
|
|
|
|
|
|
|
let current_profile = self.current_profile()?;
|
|
|
|
|
|
|
|
let mut prefix = "";
|
|
|
|
|
|
|
|
print!("[");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for profile in &self.profiles {
|
|
|
|
|
|
|
|
if current_profile.as_ref() == Some(profile) {
|
|
|
|
|
|
|
|
print!("{}{}", prefix, profile.as_str().bold().with(PROFILE_COLOR));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
print!("{}{}", prefix, profile.as_str().with(PROFILE_COLOR));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix = ", ";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
println!("]");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn save_profile(&mut self, profile_name: &str) -> Result<(), Error> {
|
|
|
|
let vcs_path = self.work_dir.join("Cargo_vcs.toml");
|
|
|
|
let vcs_path = self.work_dir.join("Cargo_vcs.toml");
|
|
|
|
let vcs = match fs::read_to_string(&vcs_path) {
|
|
|
|
let vcs = match fs::read_to_string(&vcs_path) {
|
|
|
|
Ok(val) => toml::from_str(&val)?,
|
|
|
|
Ok(val) => toml::from_str(&val)?,
|
|
|
@ -175,6 +194,10 @@ impl Vcs {
|
|
|
|
let new_contents = toml::to_string(&vcs_main)?;
|
|
|
|
let new_contents = toml::to_string(&vcs_main)?;
|
|
|
|
fs::write(vcs_path, new_contents)?;
|
|
|
|
fs::write(vcs_path, new_contents)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !&self.profiles.iter().any(|p| p == profile_name) {
|
|
|
|
|
|
|
|
self.profiles.push(profile_name.into());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
println!(
|
|
|
|
println!(
|
|
|
|
"Workspace state saved as {}",
|
|
|
|
"Workspace state saved as {}",
|
|
|
|
profile_name.with(PROFILE_COLOR),
|
|
|
|
profile_name.with(PROFILE_COLOR),
|
|
|
|