From 63f6c1fb11aac25a7dd0cbced19a0693e3679a9b Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Wed, 11 Jun 2025 16:54:33 +0000
Subject: [PATCH] chore(cli): Improve `run_command` macro
Signed-off-by: Awiteb
---
src/cli/macros.rs | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/cli/macros.rs b/src/cli/macros.rs
index b5ba9f6..5f69c00 100644
--- a/src/cli/macros.rs
+++ b/src/cli/macros.rs
@@ -33,22 +33,21 @@ pub fn get_signer_state(_v: &T) -> bool {
/// last.
#[macro_export]
macro_rules! run_command {
- (r $command:ident $options:ident) => {{
- if $crate::cli::macros::get_relays_state(&$command) {
- $options.ensure_relays()?;
- }
- if $crate::cli::macros::get_signer_state(&$command) {
- $options.ensure_signer()?;
- }
- $command.run($options).await
- }};
($command:ident, $options:ident, $($subcommands:ident)* & $($commands:ident)*) => {
match $command {
$(
Self::$subcommands { subcommands } => subcommands.run($options).await,
)*
$(
- Self::$commands ( args ) => $crate::run_command!(r args $options),
+ Self::$commands ( args ) => {
+ if $crate::cli::macros::get_relays_state(&args) {
+ $options.ensure_relays()?;
+ }
+ if $crate::cli::macros::get_signer_state(&args) {
+ $options.ensure_signer()?;
+ }
+ args.run($options).await
+ },
)*
}
};