add example config and just overall improve the config data stuff
This commit is contained in:
parent
0d0cb945a1
commit
9887d5196f
3 changed files with 83 additions and 35 deletions
41
src/main.rs
41
src/main.rs
|
@ -1,33 +1,9 @@
|
|||
use clap::Parser;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
use cli::Commands;
|
||||
use std::{collections::HashMap, path::PathBuf, process::exit};
|
||||
mod build;
|
||||
mod cli;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
struct SiteInfo {
|
||||
name: String,
|
||||
subdomain: String,
|
||||
///
|
||||
socket_address_or_port: String,
|
||||
/// What auth file to use
|
||||
auth: u8,
|
||||
conf_file: PathBuf,
|
||||
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
struct Config {
|
||||
output_dir: String,
|
||||
domain: String,
|
||||
/// Subdomains/services in the format `subdomain: SiteInfo`
|
||||
subdomains: HashMap<String, SiteInfo>,
|
||||
/// Paths to the htpasswd file for each auth number - starts at 0, goes to 255; see [`SiteInfo`]
|
||||
htpasswd_files: Vec<PathBuf>,
|
||||
/// Default IP for if it's not specified in `socket_address_or_port` in [`SiteInfo`]. Defaults to localhost if not specified.
|
||||
#[serde(default = "default_default_ip")]
|
||||
default_ip: String
|
||||
}
|
||||
mod data;
|
||||
|
||||
fn main() {
|
||||
build::completion_builder().unwrap();
|
||||
|
@ -36,11 +12,10 @@ fn main() {
|
|||
|
||||
let config = args.config;
|
||||
|
||||
if args.print_example_config {
|
||||
println!("{}", data::example_config());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
println!("Config: {}", config.to_str().unwrap())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
fn default_default_ip() -> String {
|
||||
return "localhost".to_string();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue