forked from kemitix/git-next
27 lines
934 B
Rust
27 lines
934 B
Rust
use std::io::Write;
|
|
|
|
pub(crate) fn run() {
|
|
let file_name = ".git-next.toml";
|
|
let path = std::path::Path::new(file_name);
|
|
if path.exists() {
|
|
eprintln!(
|
|
"The configuration file already exists at {} - not overwritting it.",
|
|
file_name
|
|
);
|
|
} else {
|
|
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!("../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);
|
|
}
|
|
}
|
|
}
|
|
}
|