refactor(commands): separate commands definitions and other code into modules

This commit is contained in:
dusk 2025-01-04 07:35:04 +09:00
parent 405ac11d74
commit af523a4c23
No known key found for this signature in database
24 changed files with 293 additions and 216 deletions

View file

@ -41,6 +41,14 @@ lazy_static::lazy_static!(
);
impl Token {
pub fn cmd(value: impl Into<SmolStr>) -> Self {
Self::Value(vec![value.into()])
}
pub fn cmd_with_alias(value: impl IntoIterator<Item = impl Into<SmolStr>>) -> Self {
Self::Value(value.into_iter().map(Into::into).collect())
}
pub fn try_match(&self, input: Option<SmolStr>) -> TokenMatchResult {
// short circuit on empty things
if matches!(self, Self::Empty) && input.is_none() {