diff --git a/crates/pet-reporter/src/stdio.rs b/crates/pet-reporter/src/stdio.rs index fec15194..3166f7a3 100644 --- a/crates/pet-reporter/src/stdio.rs +++ b/crates/pet-reporter/src/stdio.rs @@ -18,12 +18,14 @@ pub struct StdioReporter { print_list: bool, managers: Arc>>, environments: Arc, u16>>>, + environment_paths: Arc, Vec>>>, kind: Option, } pub struct Summary { pub managers: HashMap, pub environments: HashMap, u16>, + pub environment_paths: HashMap, Vec>, } impl StdioReporter { @@ -33,9 +35,14 @@ impl StdioReporter { .environments .lock() .expect("environments mutex poisoned"); + let environment_paths = self + .environment_paths + .lock() + .expect("environment_paths mutex poisoned"); Summary { managers: managers.clone(), environments: environments.clone(), + environment_paths: environment_paths.clone(), } } } @@ -62,6 +69,15 @@ impl Reporter for StdioReporter { .expect("environments mutex poisoned"); let count = environments.get(&env.kind).unwrap_or(&0) + 1; environments.insert(env.kind, count); + + // Store the environment details for verbose reporting + let mut environment_paths = self + .environment_paths + .lock() + .expect("environment_paths mutex poisoned"); + let paths = environment_paths.entry(env.kind).or_default(); + paths.push(env.clone()); + if self.print_list { println!("{env}") } @@ -73,6 +89,7 @@ pub fn create_reporter(print_list: bool, kind: Option) -> print_list, managers: Arc::new(Mutex::new(HashMap::new())), environments: Arc::new(Mutex::new(HashMap::new())), + environment_paths: Arc::new(Mutex::new(HashMap::new())), kind, } } diff --git a/crates/pet/src/lib.rs b/crates/pet/src/lib.rs index ce5aa02e..b4635fbd 100644 --- a/crates/pet/src/lib.rs +++ b/crates/pet/src/lib.rs @@ -47,7 +47,7 @@ pub fn initialize_tracing(verbose: bool) { if use_json { tracing_subscriber::registry() .with(filter) - .with(fmt::layer().json()) + .with(fmt::layer().json().with_writer(std::io::stderr)) .init(); } else { tracing_subscriber::registry() @@ -55,7 +55,8 @@ pub fn initialize_tracing(verbose: bool) { .with( fmt::layer() .with_target(true) - .with_timer(fmt::time::uptime()), + .with_timer(fmt::time::uptime()) + .with_writer(std::io::stderr), ) .init(); } @@ -196,6 +197,25 @@ fn find_envs( } let summary = stdio_reporter.get_summary(); + + // If verbose, print the paths of discovered environments first + if options.verbose && !summary.environment_paths.is_empty() { + println!("Environment Paths:"); + println!("------------------"); + for (kind, envs) in summary.environment_paths.iter() { + let kind_str = kind + .map(|v| format!("{v:?}")) + .unwrap_or("Unknown".to_string()); + println!("\n{kind_str}:"); + for env in envs { + if let Some(executable) = &env.executable { + println!(" - {}", executable.display()); + } + } + } + println!() + } + if !summary.managers.is_empty() { println!("Managers:"); println!("---------");