feat(server): creates a default server configuration file
The default configuration is currently blank
This commit is contained in:
parent
aa27e96d53
commit
1e3ca5b711
3 changed files with 24 additions and 0 deletions
0
server-default.toml
Normal file
0
server-default.toml
Normal file
|
@ -1,4 +1,5 @@
|
||||||
mod init;
|
mod init;
|
||||||
|
mod server;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ fn main() {
|
||||||
Command::Server(server) => match server {
|
Command::Server(server) => match server {
|
||||||
Server::Init => {
|
Server::Init => {
|
||||||
println!("Server Init command");
|
println!("Server Init command");
|
||||||
|
server::init();
|
||||||
}
|
}
|
||||||
Server::Start => {
|
Server::Start => {
|
||||||
println!("Server Start command");
|
println!("Server Start command");
|
||||||
|
|
22
src/server.rs
Normal file
22
src/server.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue