input: sexpr defcom

This commit is contained in:
🪞👃🪞 2025-04-27 01:57:10 +03:00
parent 61fd07bffd
commit fa5ff90be6

View file

@ -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 {