code complexity & repetition analysis tool
at main 47 lines 1.6 kB view raw
1use anyhow::Result; 2use mccabre_core::config::Config; 3use owo_colors::OwoColorize; 4use std::path::PathBuf; 5 6pub fn run(config_path: Option<PathBuf>, output_path: Option<PathBuf>) -> Result<()> { 7 let config = if let Some(path) = &config_path { 8 println!("{} {}", "Loading config from:".blue(), path.display()); 9 Config::from_file(path)? 10 } else { 11 println!("{}", "Using default configuration".blue()); 12 Config::load_default()? 13 }; 14 15 println!(); 16 println!("{}", "CONFIGURATION".green().bold()); 17 println!("{}", "=".repeat(80).cyan()); 18 println!(); 19 20 println!("{}", "Complexity Settings:".yellow().bold()); 21 println!(" Warning threshold: {}", config.complexity.warning_threshold); 22 println!(" Error threshold: {}", config.complexity.error_threshold); 23 println!(); 24 25 println!("{}", "Clone Detection Settings:".yellow().bold()); 26 println!(" Enabled: {}", config.clones.enabled); 27 println!(" Minimum tokens: {}", config.clones.min_tokens); 28 println!(); 29 30 println!("{}", "File Settings:".yellow().bold()); 31 println!(" Respect .gitignore: {}", config.files.respect_gitignore); 32 println!(); 33 34 println!("{}", "=".repeat(80).cyan()); 35 println!(); 36 37 if let Some(output) = output_path { 38 let save_path = if output.is_dir() { output.join("mccabre.toml") } else { output }; 39 40 config.save(&save_path)?; 41 println!("{} {}", "Configuration saved to:".green().bold(), save_path.display()); 42 } else { 43 println!("{}", "To save this configuration, use --output <path>.".dimmed()); 44 } 45 46 Ok(()) 47}