added util binary for generating default config file. also adding generated config file
This commit is contained in:
2626
Cargo.lock
generated
2626
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
11
Cargo.toml
@@ -6,6 +6,16 @@ description = "cli for building and publishing documentation using asciidoctor"
|
|||||||
license-file = "LICENSE.txt"
|
license-file = "LICENSE.txt"
|
||||||
authors = ["Quirin Ecker"]
|
authors = ["Quirin Ecker"]
|
||||||
exclude = [".gitlab", ".github"]
|
exclude = [".gitlab", ".github"]
|
||||||
|
default-run = "docki"
|
||||||
|
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "docki"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "util"
|
||||||
|
path = "src/util.rs"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@@ -25,3 +35,4 @@ clap_complete = "4.1.4"
|
|||||||
nu-ansi-term = "0.50.3"
|
nu-ansi-term = "0.50.3"
|
||||||
config = { version = "0.15.18", features = ["toml"] }
|
config = { version = "0.15.18", features = ["toml"] }
|
||||||
serde = "1.0.228"
|
serde = "1.0.228"
|
||||||
|
toml = "0.9.6"
|
||||||
|
|||||||
4
config/docki.config.toml
Normal file
4
config/docki.config.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
port = 8080
|
||||||
|
input_dir = "./docs"
|
||||||
|
offline_reveal = false
|
||||||
|
output_dir = "./dist"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::app::config::arguments::CommandArg;
|
use crate::app::config::arguments::CommandArg;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug, Serialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ pub mod build;
|
|||||||
pub mod fs_util;
|
pub mod fs_util;
|
||||||
pub mod watcher;
|
pub mod watcher;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
mod config;
|
pub mod config;
|
||||||
|
|
||||||
use std::env;
|
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