chiark / gitweb /
cli: Make SubcommandProperties const-default, not just default
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Mar 2022 12:51:47 +0000 (12:51 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Mar 2022 12:51:47 +0000 (12:51 +0000)
inventory 0.2 is going to want this.

Cargo.lock
cli/Cargo.toml
cli/clisupport.rs
cli/otter.rs

index 4768680372f3ca5e479245751c61626ef3d08c1f..1b701f9b62bcc2d4d9342eaaa1a493bf86749d02 100644 (file)
@@ -351,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7fe8c2b5119660fa0a7020d0013bfa7d3ae6e4e27084b391e057062746a7c862"
 dependencies = [
  "either",
- "proc-macro-crate",
+ "proc-macro-crate 0.1.5",
  "proc-macro-error",
  "proc-macro2 1.0.36",
  "quote 1.0.15",
@@ -474,6 +474,27 @@ dependencies = [
  "wasm-bindgen",
 ]
 
+[[package]]
+name = "const-default"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa"
+dependencies = [
+ "const-default-derive",
+]
+
+[[package]]
+name = "const-default-derive"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f814dd8cbb812233751ff6857b7fa86d9f52e88ac64e8f54e7a1ca0168f03da"
+dependencies = [
+ "proc-macro-crate 1.1.3",
+ "proc-macro2 1.0.36",
+ "quote 1.0.15",
+ "syn 1.0.86",
+]
+
 [[package]]
 name = "convert_case"
 version = "0.4.0"
@@ -2558,6 +2579,7 @@ name = "otter-cli"
 version = "0.7.3"
 dependencies = [
  "argparse",
+ "const-default",
  "directories",
  "fehler",
  "num-traits",
@@ -2921,6 +2943,16 @@ dependencies = [
  "toml 0.5.8",
 ]
 
+[[package]]
+name = "proc-macro-crate"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a"
+dependencies = [
+ "thiserror",
+ "toml 0.5.8",
+]
+
 [[package]]
 name = "proc-macro-error"
 version = "1.0.4"
index c421ee7af1fedf42c89762f9f74a06c904c413f3..52060a9e6ed9a8f1249770d28d45194dd32068a9 100644 (file)
@@ -35,6 +35,7 @@ fehler="1"
 num-traits="0.2"
 serde_with="1"
 
+const-default = { version="1",    features=["derive"      ] }
 serde        = { version="1"    , features=["derive", "rc"] }
 strum        = { version="0.24" , features=["derive"      ] }
 
index 856a491397e007e18b4bcbdf0e819a85b9a74442..71afb698dab2f67c284ecf6baa0a0d888207a1f3 100644 (file)
@@ -522,7 +522,7 @@ macro_rules! inventory_subcmd {
       verb: $verb,
       help: $help,
       call,
-      props: default(),
+      props: $crate::SubcommandProperties::DEFAULT,
     }}
   };
   {$verb:expr, $help:expr, $($prop:tt)+} => {
@@ -530,7 +530,10 @@ macro_rules! inventory_subcmd {
       verb: $verb,
       help: $help,
       call,
-      props: SubcommandProperties { $($prop)* ..default() },
+      props: SubcommandProperties {
+        $($prop)*
+        ..$crate::SubcommandProperties::DEFAULT
+      },
     }}
   };
 }
index 51c78fec4ab16c5de2522f8d069a17917d944282..fe0bef98110de67dfda7d655bac4b99d59bdf62d 100644 (file)
@@ -14,6 +14,7 @@ pub use std::rc::Rc;
 
 pub use argparse::{self,ArgumentParser,action::{TypedAction,ParseResult}};
 pub use argparse::action::{Action,IFlagAction,IArgAction};
+pub use const_default::ConstDefault;
 pub use derive_more::Display;
 
 pub use otter::prelude::*;
@@ -75,7 +76,7 @@ pub struct Subcommand {
 }
 inventory::collect!(Subcommand);
 
-#[derive(Default,Debug)]
+#[derive(ConstDefault,Debug)]
 pub struct SubcommandProperties {
   suppress_selectaccount: bool,
 }