|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
use crossterm::style::Stylize;
|
|
|
|
|
use semver::Version;
|
|
|
|
|
use std::{
|
|
|
|
|
collections::HashMap,
|
|
|
|
|
fs,
|
|
|
|
@ -94,19 +95,26 @@ impl Vcs {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn info(&self) -> Result<(), Error> {
|
|
|
|
|
pub fn status(&self) -> Result<(), Error> {
|
|
|
|
|
if let Some(profile_name) = self.current_profile()? {
|
|
|
|
|
println!(
|
|
|
|
|
"{}{} [{}]",
|
|
|
|
|
"{}{} [{}] {}",
|
|
|
|
|
"Workspace is set to profile: ".with(SUCCESS_COLOR),
|
|
|
|
|
profile_name.bold().with(PROFILE_COLOR),
|
|
|
|
|
format!("{}", self.work_dir.display()).italic(),
|
|
|
|
|
self.min_msrv_str(),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
if self.profiles.is_empty() {
|
|
|
|
|
println!("{}", "No profiles defined, use 'cargo vcs save' to generate one".with(ERROR_COLOR));
|
|
|
|
|
println!(
|
|
|
|
|
"{}",
|
|
|
|
|
"No profiles defined, use 'cargo vcs save' to generate one\n".with(ERROR_COLOR)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
println!("{}", "Mismatching projects and profiles".with(ERROR_COLOR));
|
|
|
|
|
println!(
|
|
|
|
|
"{}",
|
|
|
|
|
"Mismatching projects and profiles\n".with(ERROR_COLOR)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
self.list();
|
|
|
|
|
}
|
|
|
|
@ -118,6 +126,29 @@ impl Vcs {
|
|
|
|
|
self.projects.iter()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn min_msrv_str(&self) -> String {
|
|
|
|
|
if let Some(msrv) = self.min_msrv() {
|
|
|
|
|
format!("MSRV: {}", msrv).with(MSRV_COLOR).to_string()
|
|
|
|
|
} else {
|
|
|
|
|
String::new()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn min_msrv(&self) -> Option<&Version> {
|
|
|
|
|
let mut min_msrv = None;
|
|
|
|
|
|
|
|
|
|
for project in &self.projects {
|
|
|
|
|
let msrv = project.msrv();
|
|
|
|
|
if min_msrv.is_none() {
|
|
|
|
|
min_msrv = msrv;
|
|
|
|
|
} else if msrv.is_some() && msrv < min_msrv {
|
|
|
|
|
min_msrv = msrv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
min_msrv
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn save_profile(&self, profile_name: &str) -> Result<(), Error> {
|
|
|
|
|
let vcs_path = self.work_dir.join("Cargo_vcs.toml");
|
|
|
|
|
let vcs = match fs::read_to_string(&vcs_path) {
|
|
|
|
|