chiark / gitweb /
Config inspection: Support --print-config in hippotat
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2023 18:56:47 +0000 (18:56 +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

index e3826564c763656dc5abe5cacfa9d1712d879a25..0f3cbbf2b56273852214f3025bfc7cd9b4022e24 100644 (file)
@@ -18,6 +18,12 @@ pub struct Opts {
 
   #[clap(flatten)]
   config: config::Opts,
+
+  /// Print a config item, do not actually run
+  ///
+  /// One line is output for each association
+  #[clap(long)]
+  print_config: Option<String>,
 }
 
 type OutstandingRequest<'r> = Pin<Box<
@@ -323,7 +329,16 @@ async fn run_client<C:Hcc>(
 async fn main() {
   let opts = <Opts as clap::Parser>::parse();
   let (ics,) = config::startup("hippotat", LinkEnd::Client,
-                               &opts.config, &opts.log, |ics|Ok((ics,)));
+                               &opts.config, &opts.log, |ics| {
+    if let Some(arg) = &opts.print_config {
+      for ic in &ics {
+        ic.implement_print_config(arg)?;
+      }
+      process::exit(0);
+    }
+
+    Ok((ics,))
+  });
 
   let https = HttpsConnector::new();
   let hclient = hyper::Client::builder()