pub fn parse_player(player: Entity, mut tokenizer: Tokenizer) -> Result<Action, String> {
    if let Some(name) = tokenizer.next() {
        if let Some(token) = tokenizer.next() {
            match token {
                "errors" => {
                    if tokenizer.rest().is_empty() {
                        Err("Enter a script to look for its errors.".to_string())
                    } else {
                        let script = ScriptName::try_from(tokenizer.next().unwrap().to_string())
                            .map_err(|e| e.to_string())?;
                        Ok(Action::from(ShowError {
                            actor: player,
                            target: ActionTarget::Player(name.to_string()),
                            script,
                        }))
                    }
                }
                "info" => Ok(Action::from(PlayerInfo {
                    actor: player,
                    name: name.to_string(),
                })),
                "init" => Ok(Action::from(Initialize {
                    actor: player,
                    target: ActionTarget::Player(name.to_string()),
                })),
                "set" => {
                    if tokenizer.rest().is_empty() {
                        Err(
                            "Enter a space separated list of flags. Valid flags: immortal."
                                .to_string(),
                        )
                    } else {
                        Ok(Action::from(PlayerUpdateFlags {
                            actor: player,
                            name: name.to_string(),
                            flags: tokenizer
                                .rest()
                                .to_string()
                                .split_whitespace()
                                .map(|flag| flag.to_string())
                                .collect_vec(),
                            clear: false,
                        }))
                    }
                }
                "unset" => {
                    if tokenizer.rest().is_empty() {
                        Err(
                            "Enter a space separated list of flags. Valid flags: immortal."
                                .to_string(),
                        )
                    } else {
                        Ok(Action::from(PlayerUpdateFlags {
                            actor: player,
                            name: name.to_string(),
                            flags: tokenizer
                                .rest()
                                .to_string()
                                .split_whitespace()
                                .map(|flag| flag.to_string())
                                .collect_vec(),
                            clear: true,
                        }))
                    }
                }
                _ => Err("Enter a valid player subcommand: info.".to_string()),
            }
        } else {
            Err("Enter a player subcommand: info.".to_string())
        }
    } else {
        Err("Enter a player name.".to_string())
    }
}
// Valid shapes:
// player <name> info - displays information about the player
Valid shapes:
player  info - displays information about the player
Valid shapes : player info - displays information about the player
pub fn parse_player(player: Entity, mut tokenizer: Tokenizer) -> Result<Action, String> {
    if let Some(name) = tokenizer.next() {
        if let Some(token) = tokenizer.next() {
            match token {
                "errors" => {
                    if tokenizer.rest().is_empty() {
                        Err("Enter a script to look for its errors.".to_string())
                    } else {
                        let script = ScriptName::try_from(tokenizer.next().unwrap().to_string())
                            .map_err(|e| e.to_string())?;
                        Ok(Action::from(ShowError {
                            actor: player,
                            target: ActionTarget::Player(name.to_string()),
                            script,
                        }))
                    }
                }
                "info" => Ok(Action::from(PlayerInfo {
                    actor: player,
                    name: name.to_string(),
                })),
                "init" => Ok(Action::from(Initialize {
                    actor: player,
                    target: ActionTarget::Player(name.to_string()),
                })),
                "set" => {
                    if tokenizer.rest().is_empty() {
                        Err(
                            "Enter a space separated list of flags. Valid flags: immortal."
                                .to_string(),
                        )
                    } else {
                        Ok(Action::from(PlayerUpdateFlags {
                            actor: player,
                            name: name.to_string(),
                            flags: tokenizer
                                .rest()
                                .to_string()
                                .split_whitespace()
                                .map(|flag| flag.to_string())
                                .collect_vec(),
                            clear: false,
                        }))
                    }
                }
                "unset" => {
                    if tokenizer.rest().is_empty() {
                        Err(
                            "Enter a space separated list of flags. Valid flags: immortal."
                                .to_string(),
                        )
                    } else {
                        Ok(Action::from(PlayerUpdateFlags {
                            actor: player,
                            name: name.to_string(),
                            flags: tokenizer
                                .rest()
                                .to_string()
                                .split_whitespace()
                                .map(|flag| flag.to_string())
                                .collect_vec(),
                            clear: true,
                        }))
                    }
                }
                _ => Err("Enter a valid player subcommand: info.".to_string()),
            }
        } else {
            Err("Enter a player subcommand: info.".to_string())
        }
    } else {
        Err("Enter a player name.".to_string())
    }
}
pub fn parse_player ( player : Entity , mut tokenizer : Tokenizer ) -> Result < Action , String > { if let Some ( name ) = tokenizer . next ( ) { if let Some ( token ) = tokenizer . next ( ) { match token { " " => { if tokenizer . rest ( ) . is_empty ( ) { Err ( " " . to_string ( ) ) } else { let script = ScriptName :: try_from ( tokenizer . next ( ) . unwrap ( ) . to_string ( ) ) . map_err ( | e | e . to_string ( ) ) ? ; Ok ( Action :: from ( ShowError { actor : player , target : ActionTarget :: Player ( name . to_string ( ) ) , script , } ) ) } } " " => Ok ( Action :: from ( PlayerInfo { actor : player , name : name . to_string ( ) , } ) ) , " " => Ok ( Action :: from ( Initialize { actor : player , target : ActionTarget :: Player ( name . to_string ( ) ) , } ) ) , " " => { if tokenizer . rest ( ) . is_empty ( ) { Err ( " " . to_string ( ) , ) } else { Ok ( Action :: from ( PlayerUpdateFlags { actor : player , name : name . to_string ( ) , flags : tokenizer . rest ( ) . to_string ( ) . split_whitespace ( ) . map ( | flag | flag . to_string ( ) ) . collect_vec ( ) , clear : false , } ) ) } } " " => { if tokenizer . rest ( ) . is_empty ( ) { Err ( " " . to_string ( ) , ) } else { Ok ( Action :: from ( PlayerUpdateFlags { actor : player , name : name . to_string ( ) , flags : tokenizer . rest ( ) . to_string ( ) . split_whitespace ( ) . map ( | flag | flag . to_string ( ) ) . collect_vec ( ) , clear : true , } ) ) } } _ => Err ( " " . to_string ( ) ) , } } else { Err ( " " . to_string ( ) ) } } else { Err ( " " . to_string ( ) ) } }
Valid shapes:
player <name> info - displays information about the player
Valid shapes : player <name > info - displays information about the player
player
Entity
tokenizer
Tokenizer
player
Entity
tokenizer
Tokenizer