valence_command/parsers/
score_holder.rs
1use super::Parser;
2use crate::parsers::entity_selector::EntitySelector;
3use crate::parsers::{CommandArg, CommandArgParseError, ParseInput};
4
5#[derive(Debug, Clone, PartialEq, Eq, Default)]
6pub enum ScoreHolder {
7 Entity(EntitySelector),
8 #[default]
9 All,
10}
11
12impl CommandArg for ScoreHolder {
13 fn parse_arg(input: &mut ParseInput) -> Result<Self, CommandArgParseError> {
14 input.skip_whitespace();
15 if input.peek() == Some('*') {
16 Ok(ScoreHolder::All)
17 } else {
18 Ok(ScoreHolder::Entity(EntitySelector::parse_arg(input)?))
19 }
20 }
21
22 fn display() -> Parser {
23 Parser::ScoreHolder {
24 allow_multiple: false,
25 }
26 }
27}