From 3a867aa514e3e0ad2920233440b6b3b3ab4973b8 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 10 Jan 2023 01:44:24 +0000 Subject: [PATCH] Config inspection: "pretty" dump option, replaces --dump Signed-off-by: Ian Jackson --- client/client.rs | 10 ---------- src/config.rs | 3 +++ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/client/client.rs b/client/client.rs index 0d4a53c..52b7ec3 100644 --- a/client/client.rs +++ b/client/client.rs @@ -28,9 +28,6 @@ pub struct Opts { /// `link`: the link name including the `[ ]`. #[clap(long)] print_config: Option, - - #[clap(long, required(false))] - dump_config: bool, } type OutstandingRequest<'r> = Pin::parse(); let (ics,) = config::startup("hippotat", LinkEnd::Client, &opts.config, &opts.log, |ics| { - if opts.dump_config { - for ic in &ics { - println!("{:#?}", ic); - } - process::exit(0); - } - implement_print_config(&mut ics.iter(), &opts.print_config, &|ic, k| Some(match k { "link" => &ic.link, diff --git a/src/config.rs b/src/config.rs index 6db3c12..2d37d6e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -110,6 +110,9 @@ pub fn implement_print_config<'c, C: InspectableConfig>( let output = arg .split(',') .map(|key| { + if key == "pretty" { + return Ok(format!("{:#?}", &config)); + } let insp = config.inspect_key(key) .or_else(|| extra_key(key)) .ok_or_else(|| anyhow!("unknown config key {:?}", key))?; -- 2.30.2