forked from kemitix/git-next
feat(init): creates a default configuration file
The default configuration file is currently empty
This commit is contained in:
parent
dd124d11ae
commit
aa27e96d53
3 changed files with 25 additions and 0 deletions
0
default.toml
Normal file
0
default.toml
Normal file
22
src/init.rs
Normal file
22
src/init.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
mod init;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
@ -23,6 +25,7 @@ fn main() {
|
|||
match commands.command {
|
||||
Command::Init => {
|
||||
println!("Init command");
|
||||
init::run();
|
||||
}
|
||||
Command::Server(server) => match server {
|
||||
Server::Init => {
|
||||
|
|
Loading…
Reference in a new issue