git-next/src/server.rs

23 lines
802 B
Rust
Raw Normal View History

use std::io::Write;
pub(crate) fn init() {
let file_name = "git-next-server.toml";
let path = std::path::Path::new(file_name);
if !path.exists() {
match std::fs::File::create(file_name) {
Ok(mut file) => {
println!("Created a default configuration file at {}", file_name);
match file.write_all(include_bytes!("../server-default.toml")) {
Ok(_) => println!("Wrote to the configuration file successfully."),
Err(e) => {
eprintln!("Failed to write to the configuration file: {}", e)
}
}
}
Err(e) => {
eprintln!("Failed to create a default configuration file: {}", e);
}
}
}
}