(
path: Option<String>,
project_id: Option<String>,
project_path: Option<String>,
json: bool,
short: bool,
details: bool,
runtime: bool,
)
| 71 | } |
| 72 | |
| 73 | pub(crate) async fn handle_status_command( |
| 74 | path: Option<String>, |
| 75 | project_id: Option<String>, |
| 76 | project_path: Option<String>, |
| 77 | json: bool, |
| 78 | short: bool, |
| 79 | details: bool, |
| 80 | runtime: bool, |
| 81 | ) -> tracedecay::errors::Result<()> { |
| 82 | let project_path = resolve_cli_project_root(path, project_id, project_path).await?; |
| 83 | let cg = if TraceDecay::has_initialized_store(&project_path).await { |
| 84 | match TraceDecay::open(&project_path).await { |
| 85 | Ok(cg) => cg, |
| 86 | Err(_) => TraceDecay::open_read_only(&project_path).await?, |
| 87 | } |
| 88 | } else if !io::stdin().is_terminal() { |
| 89 | eprintln!( |
| 90 | "No TraceDecay index found at '{}'. Non-interactive: skipping index creation (run `tracedecay init`).", |
| 91 | project_path.display() |
| 92 | ); |
| 93 | return Ok(()); |
| 94 | } else { |
| 95 | eprint!( |
| 96 | "No TraceDecay index found at '{}'. Create one now? [Y/n] ", |
| 97 | project_path.display() |
| 98 | ); |
| 99 | io::stderr().flush().ok(); |
| 100 | let mut answer = String::new(); |
| 101 | io::stdin().lock().read_line(&mut answer).map_err(|e| { |
| 102 | tracedecay::errors::TraceDecayError::Config { |
| 103 | message: format!("failed to read stdin: {e}"), |
| 104 | } |
| 105 | })?; |
| 106 | let answer = answer.trim(); |
| 107 | if answer.is_empty() || answer.eq_ignore_ascii_case("y") { |
| 108 | commands::init_and_index(&project_path, &[], &[], false).await? |
| 109 | } else { |
| 110 | return Ok(()); |
| 111 | } |
| 112 | }; |
| 113 | if runtime { |
| 114 | let snap = tracedecay::runtime_telemetry::collect(&cg).await?; |
| 115 | if json { |
| 116 | println!("{}", tracedecay::runtime_telemetry::to_pretty_json(&snap)); |
| 117 | } else { |
| 118 | print!("{}", tracedecay::runtime_telemetry::to_text_report(&snap)); |
| 119 | } |
| 120 | return Ok(()); |
| 121 | } |
| 122 | let stats = cg.get_stats().await?; |
| 123 | if json { |
| 124 | println!( |
| 125 | "{}", |
| 126 | serde_json::to_string_pretty(&stats).unwrap_or_default() |
| 127 | ); |
| 128 | return Ok(()); |
| 129 | } |
| 130 |
no test coverage detected