feat: add option to activate continuous monitoring on config file
This commit is contained in:
parent
86daa0a61b
commit
411fbaf296
8 changed files with 216 additions and 30 deletions
|
|
@ -3,25 +3,44 @@ use crate::{
|
|||
cert_file_reader::CryptoFileSource,
|
||||
error::{anyhow, ensure},
|
||||
};
|
||||
use clap::Arg;
|
||||
use clap::{Arg, ArgAction};
|
||||
use rpxy_lib::{AppConfig, AppConfigList, ProxyConfig};
|
||||
|
||||
pub fn parse_opts() -> Result<String, anyhow::Error> {
|
||||
/// Parsed options
|
||||
pub struct Opts {
|
||||
pub config_file_path: String,
|
||||
pub watch: bool,
|
||||
}
|
||||
|
||||
/// Parse arg values passed from cli
|
||||
pub fn parse_opts() -> Result<Opts, anyhow::Error> {
|
||||
let _ = include_str!("../../Cargo.toml");
|
||||
let options = clap::command!().arg(
|
||||
Arg::new("config_file")
|
||||
.long("config")
|
||||
.short('c')
|
||||
.value_name("FILE")
|
||||
.required(true)
|
||||
.help("Configuration file path like ./config.toml"),
|
||||
);
|
||||
let options = clap::command!()
|
||||
.arg(
|
||||
Arg::new("config_file")
|
||||
.long("config")
|
||||
.short('c')
|
||||
.value_name("FILE")
|
||||
.required(true)
|
||||
.help("Configuration file path like ./config.toml"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("watch")
|
||||
.long("watch")
|
||||
.short('w')
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("Activate dynamic reloading of the config file via continuous monitoring"),
|
||||
);
|
||||
let matches = options.get_matches();
|
||||
|
||||
///////////////////////////////////
|
||||
let config_file_path = matches.get_one::<String>("config_file").unwrap();
|
||||
let config_file_path = matches.get_one::<String>("config_file").unwrap().to_owned();
|
||||
let watch = matches.get_one::<bool>("watch").unwrap().to_owned();
|
||||
|
||||
Ok(config_file_path.to_string())
|
||||
Ok(Opts {
|
||||
config_file_path,
|
||||
watch,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_settings(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue