My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/development/tools/cargo-workspace2/src/ops/executor.rs

33 lines
997 B

//! An op executor
use super::{versions, Print, Publish, PublishMod as Mod, PublishType};
use crate::models::{CrateId, DepGraph};
use semver::Version;
use std::path::PathBuf;
#[inline]
fn abs_path<'a>(root: &PathBuf, c_path: PathBuf, abs: bool) -> String {
if abs {
root.join(c_path).display().to_string()
} else {
c_path.display().to_string()
}
}
/// A simple print executor
pub(super) fn print(p: Print, set: Vec<CrateId>, root: PathBuf, g: &mut DepGraph) {
set.into_iter()
.map(|id| g.get_crate(id))
.map(|_crate| {
let c_path = _crate.path().clone();
match p {
Print::Name => format!("{}", _crate.name()),
Print::Path { abs } => format!("{}", abs_path(&root, c_path, abs)),
Print::Both { abs } => {
format!("{}: {}", _crate.name(), abs_path(&root, c_path, abs))
}
}
})
.for_each(|s| println!("{}", s));
}