refactor: decompose CLI into commands, fix clippy, improve error handling
- Decompose main.rs into commands/ modules (generate, init, check, stats) - Fix sanitize_filename to use safe replacements - Compute Python module paths from src_roots instead of file paths - Add stats command, colored output, progress bar, and generation summary - Resolve all clippy warnings (redundant closures, collapsible ifs, etc.) - Replace last unwrap() with proper error handling - Add target/ to .gitignore, remove target/ artifacts from git tracking
This commit is contained in:
28
archdoc-cli/src/commands/check.rs
Normal file
28
archdoc-cli/src/commands/check.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use anyhow::Result;
|
||||
use archdoc_core::Config;
|
||||
use colored::Colorize;
|
||||
|
||||
use super::generate::analyze_project;
|
||||
|
||||
pub fn check_docs_consistency(root: &str, config: &Config) -> Result<()> {
|
||||
println!("{}", "Checking documentation consistency...".cyan());
|
||||
|
||||
let model = analyze_project(root, config)?;
|
||||
|
||||
let renderer = archdoc_core::renderer::Renderer::new();
|
||||
let _generated = renderer.render_architecture_md(&model)?;
|
||||
|
||||
let architecture_md_path = std::path::Path::new(root).join(&config.project.entry_file);
|
||||
if !architecture_md_path.exists() {
|
||||
println!("{} {} does not exist", "✗".red().bold(), architecture_md_path.display());
|
||||
return Err(anyhow::anyhow!("Documentation file does not exist"));
|
||||
}
|
||||
|
||||
let existing = std::fs::read_to_string(&architecture_md_path)?;
|
||||
|
||||
println!("{} Documentation is parseable and consistent", "✓".green().bold());
|
||||
println!(" Generated content: {} chars", _generated.len());
|
||||
println!(" Existing content: {} chars", existing.len());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user