This commit is contained in:
64
src/main.rs
Normal file
64
src/main.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use std::process;
|
||||
|
||||
mod cli;
|
||||
mod core;
|
||||
mod export;
|
||||
mod models;
|
||||
mod tui;
|
||||
|
||||
use cli::Args;
|
||||
use core::analyzer::Analyzer;
|
||||
use export::exporter::Exporter;
|
||||
use tui::app::TuiApp;
|
||||
|
||||
fn main() {
|
||||
if let Err(e) = run() {
|
||||
eprintln!("Error: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
match &args.command {
|
||||
cli::Commands::Analyze(analyze_args) => {
|
||||
let analyzer = Analyzer::new(&analyze_args.path, &args.config)?;
|
||||
let items = analyzer.analyze()?;
|
||||
let exporter = Exporter::new();
|
||||
|
||||
if let Some(output) = &analyze_args.output {
|
||||
exporter.export_json(&items, output)?;
|
||||
} else {
|
||||
exporter.print_summary(&items);
|
||||
}
|
||||
}
|
||||
cli::Commands::Tui(tui_args) => {
|
||||
let analyzer = Analyzer::new(&tui_args.path, &args.config)?;
|
||||
let items = analyzer.analyze()?;
|
||||
let mut app = TuiApp::new(items, tui_args.path.clone());
|
||||
app.run()?;
|
||||
}
|
||||
cli::Commands::Export(export_args) => {
|
||||
let analyzer = Analyzer::new(&export_args.path, &args.config)?;
|
||||
let items = analyzer.analyze()?;
|
||||
let exporter = Exporter::new();
|
||||
|
||||
match export_args.format {
|
||||
cli::ExportFormat::Json => {
|
||||
exporter.export_json(&items, &export_args.output)?;
|
||||
}
|
||||
cli::ExportFormat::Markdown => {
|
||||
exporter.export_markdown(&items, &export_args.output)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
cli::Commands::Init(init_args) => {
|
||||
cli::init_config(&init_args.path)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user