git-next/src/init.rs

24 lines
675 B
Rust
Raw Normal View History

use std::path::PathBuf;
use crate::filesystem::FileSystem;
2024-04-07 16:09:16 +01:00
pub fn run(fs: FileSystem) {
let file_name = ".git-next.toml";
let path = PathBuf::from(file_name);
if fs.file_exists(&path) {
eprintln!(
"The configuration file already exists at {} - not overwritting it.",
file_name
);
} else {
match fs.write_file(file_name, 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)
}
}
}
}