From: Ian Jackson Date: Thu, 15 Jun 2023 19:15:36 +0000 (+0100) Subject: clap: Rename hippotat crate's Opts type to CommonOpts X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=36c76c3489e1dea700f0fd42bb9d61dbcb52365f;p=hippotat.git clap: Rename hippotat crate's Opts type to CommonOpts 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 --- diff --git a/client/client.rs b/client/client.rs index 2a1f2de..7511c87 100644 --- a/client/client.rs +++ b/client/client.rs @@ -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 /// diff --git a/server/server.rs b/server/server.rs index d535fa4..d9d6302 100644 --- a/server/server.rs +++ b/server/server.rs @@ -25,7 +25,7 @@ pub struct Opts { pub log: LogOpts, #[clap(flatten)] - pub config: config::Opts, + pub config: config::CommonOpts, /// Daemonise #[clap(long)] diff --git a/src/config.rs b/src/config.rs index 728a04b..e001dfd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, Vec) { let agg = (||{ @@ -1040,7 +1040,7 @@ pub fn read(opts: &Opts, end: LinkEnd) } pub fn startup(progname: &str, end: LinkEnd, - opts: &Opts, logopts: &LogOpts, + opts: &CommonOpts, logopts: &LogOpts, f: F, g: G) -> U where F: FnOnce(Option, &[InstanceConfig]) -> Result, G: FnOnce(T, Vec) -> Result,