2024-04-07 11:52:47 +01:00
|
|
|
use std::path::PathBuf;
|
2024-04-06 18:39:20 +01:00
|
|
|
|
2024-04-28 08:05:09 +01:00
|
|
|
use kxio::fs::FileSystem;
|
2024-04-07 11:52:47 +01:00
|
|
|
|
2024-04-07 16:09:16 +01:00
|
|
|
pub fn run(fs: FileSystem) {
|
2024-04-06 18:39:20 +01:00
|
|
|
let file_name = ".git-next.toml";
|
2024-04-28 08:05:09 +01:00
|
|
|
let pathbuf = PathBuf::from(file_name);
|
|
|
|
let Ok(exists) = fs.path_exists(&pathbuf) else {
|
|
|
|
eprintln!("Could not check if file exist: {}", file_name);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
if exists {
|
2024-04-07 08:56:33 +01:00
|
|
|
eprintln!(
|
|
|
|
"The configuration file already exists at {} - not overwritting it.",
|
|
|
|
file_name
|
|
|
|
);
|
|
|
|
} else {
|
2024-04-28 08:05:09 +01:00
|
|
|
match fs.file_write(&pathbuf, include_str!("../default.toml")) {
|
2024-04-07 11:52:47 +01:00
|
|
|
Ok(_) => {
|
2024-04-06 18:39:20 +01:00
|
|
|
println!("Created a default configuration file at {}", file_name);
|
|
|
|
}
|
|
|
|
Err(e) => {
|
2024-04-07 11:52:47 +01:00
|
|
|
eprintln!("Failed to write to the configuration file: {}", e)
|
2024-04-06 18:39:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|