use anyhow::Result;
use kodegraf_core::config::Config;
use kodegraf_core::graph::GraphStore;
pub fn run() -> Result<()> {
let repo_root = kodegraf_core::config::find_repo_root()?;
let db_path = Config::graph_db_path(&repo_root);
if !db_path.exists() {
println!("Kodegraf is not initialized in this project.");
println!("Run `kodegraf init` to get started.");
return Ok(());
}
let store = GraphStore::open(&db_path)?;
let stats = store.get_stats()?;
println!("Kodegraf Status");
println!("===============");
println!();
println!("Nodes: {} total", stats.total_nodes);
println!(" Files: {}", stats.files);
println!(" Functions: {}", stats.functions);
println!(" Classes: {}", stats.classes);
println!(" Types: {}", stats.types);
println!(" Enums: {}", stats.enums);
println!(" Tests: {}", stats.tests);
println!();
println!("Edges: {}", stats.total_edges);
println!();
println!(
"Languages: {}",
if stats.languages.is_empty() {
"(none)".to_string()
} else {
stats.languages.join(", ")
}
);
println!();
if let Some(last_built) = &stats.last_built {
println!("Last built: {}", last_built);
} else {
println!("Never built. Run `kodegraf build` to parse your codebase.");
}
if let Some(git_ref) = &stats.git_ref {
println!("Git ref: {}", git_ref);
}
Ok(())
}