feat(commands): allow commands to not be suggested

This commit is contained in:
dusk 2025-01-11 23:05:29 +09:00
parent f0d287b873
commit 58f07c3baa
No known key found for this signature in database
3 changed files with 14 additions and 6 deletions

View file

@ -33,6 +33,7 @@ pub struct Command {
pub tokens: Vec<Token>,
pub help: SmolStr,
pub cb: SmolStr,
pub show_in_suggestions: bool,
}
impl Command {
@ -40,11 +41,13 @@ impl Command {
tokens: impl IntoIterator<Item = Token>,
help: impl Into<SmolStr>,
cb: impl Into<SmolStr>,
show_in_suggestions: bool,
) -> Self {
Self {
tokens: tokens.into_iter().collect(),
help: help.into(),
cb: cb.into(),
show_in_suggestions,
}
}
}
@ -63,8 +66,11 @@ impl Display for Command {
#[macro_export]
macro_rules! command {
([$($v:expr),+], $cb:expr, $help:expr, suggest = $suggest:expr) => {
$crate::commands::Command::new([$($v.to_token()),*], $help, $cb, $suggest)
};
([$($v:expr),+], $cb:expr, $help:expr) => {
$crate::commands::Command::new([$($v.to_token()),*], $help, $cb)
$crate::command!([$($v),+], $cb, $help, suggest = true)
};
}