chiark / gitweb /
Config inspection: "pretty" dump option, replaces --dump
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Jan 2023 01:44:24 +0000 (01:44 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 11 Jan 2023 02:12:41 +0000 (02:12 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
client/client.rs
src/config.rs

index 0d4a53c0163115889d5980e508b2a11fcccddbe1..52b7ec390c1d7479b46604d5ac358192e5d5a3a9 100644 (file)
@@ -28,9 +28,6 @@ pub struct Opts {
   /// `link`: the link name including the `[ ]`.
   #[clap(long)]
   print_config: Option<String>,
-
-  #[clap(long, required(false))]
-  dump_config: bool,
 }
 
 type OutstandingRequest<'r> = Pin<Box<
@@ -337,13 +334,6 @@ async fn main() {
   let opts = <Opts as clap::Parser>::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,
index 6db3c12f36ae60c5be48bbcaf29dd34b0ee528f5..2d37d6e5c43c528e7647ab9199aa9eb0f1198396 100644 (file)
@@ -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))?;