use std::path::PathBuf;
pub fn find_project_root() -> PathBuf {
let mut current = std::env::current_dir().unwrap();
println!("Starting search from: {:?}", current);
loop {
let cargo_toml = current.join("Cargo.toml");
if cargo_toml.exists() {
if let Ok(content) = std::fs::read_to_string(&cargo_toml) {
if content.contains("[workspace]") {
println!("Found workspace root at: {:?}", current);
return current;
}
}
}
if !current.pop() {
panic!("Could not find workspace root (Cargo.toml with [workspace])");
}
}
}