feat(init): log when not overwritting exiting file

This commit is contained in:
Paul Campbell 2024-04-07 08:56:33 +01:00
parent e25ff500d8
commit d341647d7d
2 changed files with 12 additions and 2 deletions

View file

@ -3,7 +3,12 @@ use std::io::Write;
pub(crate) fn run() {
let file_name = ".git-next.toml";
let path = std::path::Path::new(file_name);
if !path.exists() {
if path.exists() {
eprintln!(
"The configuration file already exists at {} - not overwritting it.",
file_name
);
} else {
match std::fs::File::create(file_name) {
Ok(mut file) => {
println!("Created a default configuration file at {}", file_name);

View file

@ -5,7 +5,12 @@ use tracing::info;
pub(crate) fn init() {
let file_name = "git-next-server.toml";
let path = std::path::Path::new(file_name);
if !path.exists() {
if path.exists() {
eprintln!(
"The configuration file already exists at {} - not overwritting it.",
file_name
);
} else {
match std::fs::File::create(file_name) {
Ok(mut file) => {
println!("Created a default configuration file at {}", file_name);