MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / handle_status_command

Function handle_status_command

src/status_cmd.rs:73–235  ·  view source on GitHub ↗
(
    path: Option<String>,
    project_id: Option<String>,
    project_path: Option<String>,
    json: bool,
    short: bool,
    details: bool,
    runtime: bool,
)

Source from the content-addressed store, hash-verified

71}
72
73pub(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

Callers 1

dispatch_commandFunction · 0.85

Calls 15

resolve_cli_project_rootFunction · 0.85
open_read_onlyFunction · 0.85
init_and_indexFunction · 0.85
current_unix_timestampFunction · 0.85
fetch_worldwide_totalFunction · 0.85
fetch_country_flagsFunction · 0.85
get_tracedecay_dirFunction · 0.85
load_branch_metaFunction · 0.85
ingestFunction · 0.85
quick_cost_summaryFunction · 0.85
print_status_headerFunction · 0.85
print_status_tableFunction · 0.85

Tested by

no test coverage detected