Implement CLI argument parsing with clap and config file loading
- Add Cli struct with clap derive macros for --config, --validate, --allow-wildcard-bind flags - Config loading: reads TOML, deserializes into StaticConfig + DynamicConfig, validates - --validate: load, validate, print success/errors, exit 0 or 1 - --allow-wildcard-bind is OR'd with config allow_wildcard_bind field - Default config path: /etc/reverse-proxy/config.toml - Version from Cargo.toml via clap - Unit tests for CLI argument parsing and config loading - Integration tests for --validate with valid/invalid config and --allow-wildcard-bind
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -1,3 +1,22 @@
|
||||
use reverse_proxy::cli;
|
||||
|
||||
fn main() {
|
||||
tracing::info!("reverse-proxy starting");
|
||||
let args = cli::parse();
|
||||
|
||||
if args.validate {
|
||||
match cli::run_validate(&args) {
|
||||
Ok(()) => std::process::exit(0),
|
||||
Err(_) => std::process::exit(1),
|
||||
}
|
||||
}
|
||||
|
||||
match cli::load_config(&args) {
|
||||
Ok(_config) => {
|
||||
tracing::info!("reverse-proxy starting");
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("error: {e:#}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user