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:
2026-06-11 13:12:28 +00:00
parent 2791070971
commit d89ab71f85
5 changed files with 553 additions and 7 deletions

View File

@@ -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);
}
}
}