fix(cli): Don't silently overwrite existing config file

This commit is contained in:
Andrew Hlynskyi 2021-06-27 03:03:47 +03:00
parent 2b83500b74
commit 2e2b239c42
2 changed files with 7 additions and 1 deletions

View file

@ -194,6 +194,12 @@ fn run() -> Result<()> {
match matches.subcommand() {
("init-config", Some(_)) => {
if let Ok(Some(config_path)) = Config::find_config_file() {
return Err(anyhow!(
"Remove your existing config file first: {}",
config_path.to_string_lossy()
));
}
let mut config = Config::initial()?;
config.add(tree_sitter_loader::Config::initial())?;
config.add(tree_sitter_cli::highlight::ThemeConfig::default())?;