code complexity & repetition analysis tool
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

save config to file

+68 -6
+12 -4
crates/cli/src/commands/dump_config.rs
··· 3 3 use owo_colors::OwoColorize; 4 4 use std::path::PathBuf; 5 5 6 - pub fn run(config_path: Option<PathBuf>) -> Result<()> { 7 - let config = if let Some(path) = config_path { 6 + pub fn run(config_path: Option<PathBuf>, output_path: Option<PathBuf>) -> Result<()> { 7 + let config = if let Some(path) = &config_path { 8 8 println!("{} {}", "Loading config from:".blue(), path.display()); 9 - Config::from_file(&path)? 9 + Config::from_file(path)? 10 10 } else { 11 11 println!("{}", "Using default configuration".blue()); 12 12 Config::load_default()? ··· 33 33 34 34 println!("{}", "=".repeat(80).cyan()); 35 35 println!(); 36 - println!("{}", "To save this configuration, create a mccabre.toml file.".dimmed()); 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 + } 37 45 38 46 Ok(()) 39 47 }
+5 -1
crates/cli/src/main.rs
··· 93 93 /// Path to config file (if not specified, shows defaults) 94 94 #[arg(short, long)] 95 95 config: Option<PathBuf>, 96 + 97 + /// Save configuration to file (file path or directory) 98 + #[arg(short = 'o', long)] 99 + output: Option<PathBuf>, 96 100 }, 97 101 } 98 102 ··· 112 116 commands::clones::run(path, json, Some(min_tokens), config, !no_gitignore) 113 117 } 114 118 115 - Commands::DumpConfig { config } => commands::dump_config::run(config), 119 + Commands::DumpConfig { config, output } => commands::dump_config::run(config, output), 116 120 } 117 121 }
+11 -1
docs/src/cli-reference.md
··· 98 98 99 99 ### `dump-config` 100 100 101 - Display current configuration. 101 + Display and optionally save current configuration. 102 102 103 103 ```bash 104 104 mccabre dump-config [OPTIONS] ··· 107 107 **Options:** 108 108 109 109 - `-c, --config <FILE>` - Path to config file (shows default if not specified) 110 + - `-o, --output <PATH>` - Save configuration to file or directory 110 111 111 112 **Examples:** 112 113 ··· 116 117 117 118 # Show loaded configuration 118 119 mccabre dump-config --config mccabre.toml 120 + 121 + # Save default config to file 122 + mccabre dump-config -o my-config.toml 123 + 124 + # Save config to directory (creates mccabre.toml) 125 + mccabre dump-config -o ./configs/ 126 + 127 + # Load and save to new location 128 + mccabre dump-config -c old-config.toml -o new-config.toml 119 129 ``` 120 130 121 131 ## Global Options
+24
docs/src/configuration.md
··· 27 27 respect_gitignore = true 28 28 ``` 29 29 30 + ### Generating a Config File 31 + 32 + You can generate a config file using the `dump-config` command: 33 + 34 + ```bash 35 + # Save default config to current directory 36 + mccabre dump-config -o mccabre.toml 37 + 38 + # Save to a specific location 39 + mccabre dump-config -o /path/to/config.toml 40 + 41 + # Save to a directory (creates mccabre.toml in that directory) 42 + mccabre dump-config -o ./configs/ 43 + 44 + # Load existing config and save to new location 45 + mccabre dump-config -c old-config.toml -o new-config.toml 46 + ``` 47 + 48 + This is useful for: 49 + 50 + - Creating a starting point for customization 51 + - Copying configurations between projects 52 + - Version controlling your settings 53 + 30 54 ## Configuration Options 31 55 32 56 ### Complexity Settings
+16
docs/src/examples.md
··· 248 248 mccabre analyze src/ --json | jq '.summary' 249 249 ``` 250 250 251 + ### Generate and Save Configuration 252 + 253 + Create a config file for your project: 254 + 255 + ```bash 256 + # Save default config to current directory 257 + mccabre dump-config -o mccabre.toml 258 + 259 + # Generate config for a specific project structure 260 + cd my-project/ 261 + mccabre dump-config -o . 262 + 263 + # Copy config from one project to another 264 + mccabre dump-config -c ../project-a/mccabre.toml -o ./mccabre.toml 265 + ``` 266 + 251 267 ## Tips and Tricks 252 268 253 269 ### Incremental Analysis