fix: send correct error message if a parsed command is not implemented, etc

This commit is contained in:
dusk 2025-01-05 02:21:23 +09:00
parent 2027da40ad
commit 1a781014bd
No known key found for this signature in database
7 changed files with 31 additions and 33 deletions

View file

@ -18,6 +18,9 @@ pub enum Token {
MemberRef,
MemberPrivacyTarget,
/// System reference
SystemRef,
PrivacyLevel,
// currently not included in command definitions
@ -32,13 +35,7 @@ pub enum TokenMatchResult {
}
// move this somewhere else
lazy_static::lazy_static!(
static ref MEMBER_PRIVACY_TARGETS: Vec<SmolStr> = [
"visibility",
"name",
"todo",
].into_iter().map(SmolStr::new_static).collect();
);
const MEMBER_PRIVACY_TARGETS: &[&str] = &["visibility", "name", "todo"];
impl Token {
pub fn try_match(&self, input: Option<SmolStr>) -> TokenMatchResult {
@ -66,12 +63,9 @@ impl Token {
}
Self::MultiValue(_) => todo!(),
Self::FullString => return TokenMatchResult::Match(Some(input)),
Self::SystemRef => return TokenMatchResult::Match(Some(input)),
Self::MemberRef => return TokenMatchResult::Match(Some(input)),
Self::MemberPrivacyTarget
if MEMBER_PRIVACY_TARGETS
.iter()
.any(|target| target.eq(input.trim())) =>
{
Self::MemberPrivacyTarget if MEMBER_PRIVACY_TARGETS.contains(&input.trim()) => {
return TokenMatchResult::Match(Some(input))
}
Self::MemberPrivacyTarget => {}
@ -107,4 +101,4 @@ impl ToToken for [&str] {
fn to_token(&self) -> Token {
Token::Value(self.into_iter().map(|s| s.to_smolstr()).collect())
}
}
}