diff --git a/TODO.md b/TODO.md index fa3d7e9..9c296d7 100644 --- a/TODO.md +++ b/TODO.md @@ -43,9 +43,6 @@ ## Low priority -* config - * add flag to print parsed config when starting - * aquatic_udp * what poll event capacity is actually needed? * stagger connection cleaning intervals? diff --git a/aquatic_common/src/cli.rs b/aquatic_common/src/cli.rs index 4763092..6c9a2e0 100644 --- a/aquatic_common/src/cli.rs +++ b/aquatic_common/src/cli.rs @@ -26,7 +26,7 @@ impl Default for LogLevel { } } -pub trait Config: Default + TomlConfig + DeserializeOwned { +pub trait Config: Default + TomlConfig + DeserializeOwned + std::fmt::Debug { fn get_log_level(&self) -> Option { None } @@ -36,6 +36,7 @@ pub trait Config: Default + TomlConfig + DeserializeOwned { pub struct Options { config_file: Option, print_config: bool, + print_parsed_config: bool, print_version: bool, } @@ -59,6 +60,9 @@ impl Options { "-p" | "--print-config" => { options.print_config = true; } + "-P" => { + options.print_parsed_config = true; + } "-v" | "--version" => { options.print_version = true; } @@ -148,6 +152,10 @@ where start_logger(log_level)?; } + if options.print_parsed_config { + println!("Running with configuration: {:#?}", config); + } + app_fn(config) } } @@ -162,6 +170,7 @@ where println!(" -c, --config-file Load config from this path"); println!(" -h, --help Print this help message"); println!(" -p, --print-config Print default config"); + println!(" -P Print parsed config"); println!(" -v, --version Print version information"); if let Some(error) = opt_error {