@@ -17,7 +17,10 @@ pub fn config_file() -> PathBuf {
17pub fn generate_config_file() -> bat::errors::Result<()> {
17pub fn generate_config_file() -> bat::errors::Result<()> {
18 let config_file = config_file();
18 let config_file = config_file();
19 if config_file.exists() {
19 if config_file.exists() {
20− println!("A config file already exists at: {}", config_file.to_string_lossy());
21+ "A config file already exists at: {}",
22+ config_file.to_string_lossy()
22 print!("Overwrite? (y/N): ");
25 print!("Overwrite? (y/N): ");
23 io::stdout().flush()?;
26 io::stdout().flush()?;
@@ -31,7 +34,12 @@ pub fn generate_config_file() -> bat::errors::Result<()> {
31 let config_dir = config_file.parent();
34 let config_dir = config_file.parent();
32 match config_dir {
35 match config_dir {
33 Some(path) => fs::create_dir_all(path)?,
36 Some(path) => fs::create_dir_all(path)?,
38+ return Ok(Err(format!(
39+ "Unable to write config file to: {}",
34− None => return Ok(Err(format!("Unable to write config file to: {}", config_file.to_string_lossy()))?),
40+ config_file.to_string_lossy()
@@ -54,7 +62,10 @@ pub fn generate_config_file() -> bat::errors::Result<()> {
56 fs::write(&config_file, default_config)?;
64 fs::write(&config_file, default_config)?;
57− println!("Success! Config file written to {}", config_file.to_string_lossy());
66+ "Success! Config file written to {}",
67+ config_file.to_string_lossy()
59 return Ok(());
70 return Ok(());