28 lines
939 B
Rust
28 lines
939 B
Rust
use kxio::fs::FileSystem;
|
|
|
|
pub fn run(fs: FileSystem) {
|
|
let file_name = ".git-next.toml";
|
|
let pathbuf = fs.base().join(file_name);
|
|
match fs.path_exists(&pathbuf) {
|
|
Ok(exists) => {
|
|
if exists {
|
|
eprintln!(
|
|
"The configuration file already exists at {} - not overwritting it.",
|
|
file_name
|
|
);
|
|
} else {
|
|
match fs.file_write(&pathbuf, include_str!("../default.toml")) {
|
|
Ok(_) => {
|
|
println!("Created a default configuration file at {}", file_name);
|
|
}
|
|
Err(e) => {
|
|
eprintln!("Failed to write to the configuration file: {}", e)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Err(err) => {
|
|
eprintln!("Could not check if file exist: {} - {err:?}", file_name);
|
|
}
|
|
}
|
|
}
|