mod cli; mod config; mod fsops; mod llm; mod media; mod metadata; mod output; mod parse; mod pipeline; mod report; mod utils; use anyhow::Result; use clap::{CommandFactory, Parser}; use clap_complete::{generate, Shell}; use crate::cli::{Cli, CompletionShell}; fn main() -> Result<()> { if std::env::args_os().len() == 1 { let path = config::init_default_config()?; eprintln!("Config file: {} (edit to set API keys and defaults)", path.display()); return Ok(()); } let cli = Cli::parse(); if let Some(shell) = cli.completions.clone() { let mut cmd = Cli::command(); let shell = match shell { CompletionShell::Bash => Shell::Bash, CompletionShell::Zsh => Shell::Zsh, CompletionShell::Fish => Shell::Fish, }; generate(shell, &mut cmd, "mov-renamarr", &mut std::io::stdout()); return Ok(()); } let settings = config::build_settings(&cli)?; if cli.print_config { let rendered = config::format_settings(&settings)?; println!("{rendered}"); return Ok(()); } let report_format = settings.report_format.clone(); let report_path = settings.report_path.clone(); let dry_run_summary = settings.dry_run_summary; let report = pipeline::run(settings)?; if dry_run_summary && report_path.is_none() && matches!(report_format, crate::cli::ReportFormat::Text) { report.write_summary(None)?; } else { report.write(&report_format, report_path.as_deref())?; } Ok(()) }