added util binary for generating default config file. also adding generated config file
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::app::config::arguments::CommandArg;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct Config {
|
||||
pub port: u16,
|
||||
|
||||
@@ -3,7 +3,7 @@ pub mod build;
|
||||
pub mod fs_util;
|
||||
pub mod watcher;
|
||||
pub mod log;
|
||||
mod config;
|
||||
pub mod config;
|
||||
|
||||
use std::env;
|
||||
|
||||
|
||||
34
src/util.rs
Normal file
34
src/util.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
mod app;
|
||||
|
||||
use std::{fs::File, io::Write};
|
||||
|
||||
use app::config::config::Config;
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Args {
|
||||
#[command(subcommand)]
|
||||
pub command: CommandArg,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum CommandArg {
|
||||
/// Generates a default docki.config.toml
|
||||
GenerateDefaultConfig,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
match args.command {
|
||||
CommandArg::GenerateDefaultConfig => generate_default_config(),
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_default_config() {
|
||||
let default_config = Config::default();
|
||||
let target_file = "config/docki.config.toml";
|
||||
let mut file = File::create(target_file).unwrap();
|
||||
let output = toml::to_string_pretty(&default_config).unwrap();
|
||||
|
||||
file.write_all(output.as_bytes()).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user