chiark / gitweb /
clap: Rename hippotat crate's Opts type to CommonOpts
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Jun 2023 19:15:36 +0000 (20:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Jun 2023 20:15:29 +0000 (21:15 +0100)
clap 4 seems to index these by bare type name (!)
and panics if they aren't unique (!!)

    running 1 test
    test verify_cli ... FAILED

    failures:

    ---- verify_cli stdout ----
    thread 'verify_cli' panicked at 'Command hippotat: Argument group name must be unique

    'Opts' is already in use', /home/rustcargo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.3.4/src/builder/debug_asserts.rs:278:9
    stack backtrace:
       0: rust_begin_unwind
 at /rustc/071f14baae931e17a5a99366bf216e76384cc4f6/library/std/src/panicking.rs:578:5
       1: core::panicking::panic_fmt
 at /rustc/071f14baae931e17a5a99366bf216e76384cc4f6/library/core/src/panicking.rs:67:14
       2: clap_builder::builder::debug_asserts::assert_app
 at /home/rustcargo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.3.4/src/builder/debug_asserts.rs:278:9
       3: clap_builder::builder::command::Command::_build_self
 at /home/rustcargo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.3.4/src/builder/command.rs:3945:13
       4: clap_builder::builder::command::Command::_build_recursive
 at /home/rustcargo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.3.4/src/builder/command.rs:3843:9
       5: clap_builder::builder::command::Command::build
 at /home/rustcargo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.3.4/src/builder/command.rs:3838:9
       6: clap_builder::builder::command::Command::debug_assert
 at /home/rustcargo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.3.4/src/builder/command.rs:489:9
       7: hippotat::utils::verify_cli
 at ./src/utils.rs:236:3
       8: hippotat::verify_cli
 at ./client/client.rs:383:3
       9: hippotat::verify_cli::{{closure}}
 at ./client/client.rs:382:17
      10: core::ops::function::FnOnce::call_once
 at /rustc/071f14baae931e17a5a99366bf216e76384cc4f6/library/core/src/ops/function.rs:250:5
      11: core::ops::function::FnOnce::call_once
 at /rustc/071f14baae931e17a5a99366bf216e76384cc4f6/library/core/src/ops/function.rs:250:5
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

    failures:
verify_cli

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
client/client.rs
server/server.rs
src/config.rs

index 2a1f2deb231b63cb2f1a8b73704e0318786875cc..7511c87fcae4cc89d5518c8ade945192813bf676 100644 (file)
@@ -17,7 +17,7 @@ pub struct Opts {
   log: LogOpts,
 
   #[clap(flatten)]
-  config: config::Opts,
+  config: config::CommonOpts,
 
   /// Print config item(s), do not actually run
   ///
index d535fa4eb8660b02258dff4606388595d5ada62d..d9d63023fd085119c74035c61d1f6b175cd7766f 100644 (file)
@@ -25,7 +25,7 @@ pub struct Opts {
   pub log: LogOpts,
 
   #[clap(flatten)]
-  pub config: config::Opts,
+  pub config: config::CommonOpts,
 
   /// Daemonise
   #[clap(long)]
index 728a04b1b5296f5bacac0c5f488fb1897cc1a3a3..e001dfd4b3a9f5135a398d0140c19b8f3146ac02 100644 (file)
@@ -76,7 +76,7 @@ target_requests_outstanding = 10
 "#;
 
 #[derive(clap::Args,Debug)]
-pub struct Opts {
+pub struct CommonOpts {
   /// Top-level config file or directory
   ///
   /// Look for `main.cfg`, `config.d` and `secrets.d` here.
@@ -278,7 +278,7 @@ impl<'v> RawValRef<'v,'_,'_> {
 }
 
 pub struct Config {
-  pub opts: Opts,
+  pub opts: CommonOpts,
 }
 
 static OUTSIDE_SECTION: &str = "[";
@@ -978,7 +978,7 @@ impl<'i,T> ResolveGlobal<'i> for T where T: Eq + Clone + Debug + 'i {
 }
 
 #[throws(AE)]
-pub fn read(opts: &Opts, end: LinkEnd)
+pub fn read(opts: &CommonOpts, end: LinkEnd)
             -> (Option<ServerName>, Vec<InstanceConfig>)
 {
   let agg = (||{
@@ -1040,7 +1040,7 @@ pub fn read(opts: &Opts, end: LinkEnd)
 }
 
 pub fn startup<F,T,G,U>(progname: &str, end: LinkEnd,
-                    opts: &Opts, logopts: &LogOpts,
+                    opts: &CommonOpts, logopts: &LogOpts,
                     f: F, g: G) -> U
 where F: FnOnce(Option<ServerName>, &[InstanceConfig]) -> Result<T,AE>,
       G: FnOnce(T, Vec<InstanceConfig>) -> Result<U,AE>,