2024-04-07 11:52:47 +01:00
|
|
|
use std::path::PathBuf;
|
2024-04-06 18:39:20 +01:00
|
|
|
|
2024-04-07 11:52:47 +01:00
|
|
|
use crate::filesystem::FileSystem;
|
|
|
|
|
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-07 11:52:47 +01:00
|
|
|
let path = PathBuf::from(file_name);
|
|
|
|
if fs.file_exists(&path) {
|
2024-04-07 08:56:33 +01:00
|
|
|
eprintln!(
|
|
|
|
"The configuration file already exists at {} - not overwritting it.",
|
|
|
|
file_name
|
|
|
|
);
|
|
|
|
} else {
|
2024-04-07 11:52:47 +01:00
|
|
|
match fs.write_file(file_name, include_str!("../default.toml")) {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|