git-next/crates/cli/src/init.rs
Paul Campbell e2b545ae39
All checks were successful
Rust / build (push) Successful in 1m22s
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
fix: move default.toml inside crate that uses it
2024-07-14 20:22:32 +01:00

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);
}
}
}