mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-23 00:24:17 +02:00
Avoid overwriting existing config with --seed-config
This commit is contained in:
parent
0c0b8d8f57
commit
e8aa36beb3
2 changed files with 9 additions and 2 deletions
|
|
@ -208,10 +208,17 @@ pub fn make_default_syntax_config() -> Result<PathBuf, TealdeerError> {
|
|||
}
|
||||
}
|
||||
|
||||
let syntax_config_file_path = config_dir.join(SYNTAX_CONFIG_FILE_NAME);
|
||||
if syntax_config_file_path.is_file() {
|
||||
return Err(ConfigError(format!(
|
||||
"A configuration file already exists at {}, no action was taken.",
|
||||
syntax_config_file_path.to_str().unwrap()
|
||||
)));
|
||||
}
|
||||
|
||||
let serialized_syntax_config = toml::to_string(&RawConfig::new())
|
||||
.map_err(|err| ConfigError(format!("Failed to serialize default syntax config: {}", err)))?;
|
||||
|
||||
let syntax_config_file_path = config_dir.join(SYNTAX_CONFIG_FILE_NAME);
|
||||
let mut syntax_config_file = fs::File::create(&syntax_config_file_path)
|
||||
.map_err(map_io_err_to_config_err)?;
|
||||
let _wc = syntax_config_file.write(serialized_syntax_config.as_bytes())
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ fn main() {
|
|||
process::exit(0);
|
||||
},
|
||||
Err(ConfigError(msg)) => {
|
||||
eprintln!("Could not look up syntax_config_path: {}", msg);
|
||||
eprintln!("Could not create seed config: {}", msg);
|
||||
process::exit(1);
|
||||
},
|
||||
Err(_) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue