diff --git a/input/src/command.rs b/input/src/command.rs index d15f78a..9204c20 100644 --- a/input/src/command.rs +++ b/input/src/command.rs @@ -1,6 +1,16 @@ use crate::*; #[macro_export] macro_rules! defcom { + ([$self:ident, $app:ident:$App:ty] $(($Command:ident $(( + $Variant:ident [$($($param:ident: $Param:ty),+)?] $expr:expr + ))*))*) => { + $(#[derive(Clone, Debug)] pub enum $Command { + $($Variant $(($($Param),+))?),* + })* + $(command!(|$self: $Command, $app: $App|match $self { + $($Command::$Variant $(($($param),+))? => $expr),* + });)* + }; (|$self:ident, $app:ident:$App:ty| $($Command:ident { $( $Variant:ident $(($($param:ident: $Param:ty),+))? => $expr:expr )* $(,)? })*) => { @@ -10,7 +20,7 @@ use crate::*; $(command!(|$self: $Command, $app: $App|match $self { $($Command::$Variant $(($($param),+))? => $expr),* });)* - } + }; } #[macro_export] macro_rules! command {