mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 09:10:14 +00:00
feat(commands): implement Display traits for Token and Command to have some basic 'doc gen', split Toggle into Enable and Disable
This commit is contained in:
parent
482c923507
commit
4f7e9c22a1
9 changed files with 187 additions and 56 deletions
|
|
@ -40,9 +40,9 @@ pub enum CommandResult {
|
|||
pub enum Parameter {
|
||||
MemberRef { member: String },
|
||||
SystemRef { system: String },
|
||||
MemberPrivacyTarget { target: String },
|
||||
PrivacyLevel { level: String },
|
||||
OpaqueString { raw: String },
|
||||
MemberPrivacyTarget { target: String },
|
||||
PrivacyLevel { level: String },
|
||||
OpaqueString { raw: String },
|
||||
Toggle { toggle: bool },
|
||||
Reset,
|
||||
}
|
||||
|
|
@ -109,6 +109,7 @@ fn parse_command(input: String) -> CommandResult {
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
// todo: check if last token is a common incorrect unquote (multi-member names etc)
|
||||
// todo: check if this is a system name in pk;s command
|
||||
return CommandResult::Err {
|
||||
|
|
@ -161,8 +162,14 @@ fn next_token(
|
|||
// for FullString just send the whole string
|
||||
let input_to_match = param.clone().map(|v| v.0);
|
||||
match token.try_match(input_to_match) {
|
||||
TokenMatchResult::Match(value) => return Ok((token, value, param.map(|v| v.1).unwrap_or(current_pos))),
|
||||
TokenMatchResult::MissingParameter { name } => return Err(Some(format_smolstr!("Missing parameter `{name}` in command `{input} [{name}]`."))),
|
||||
TokenMatchResult::Match(value) => {
|
||||
return Ok((token, value, param.map(|v| v.1).unwrap_or(current_pos)))
|
||||
}
|
||||
TokenMatchResult::MissingParameter { name } => {
|
||||
return Err(Some(format_smolstr!(
|
||||
"Missing parameter `{name}` in command `{input} [{name}]`."
|
||||
)))
|
||||
}
|
||||
TokenMatchResult::NoMatch => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue