pub struct Parser {
pub command_prefix: char,
pub prop_delimeter: char,
pub namespace_delimeter: Cow<'static, str>,
}Expand description
Parser provides parsing command strings into ParsedCommand objects.
It allows you to specify the symbols that will be used to interpret the command string, such as the command delimiter, property delimiter, and namespace delimiter.
use wca::{ Parser, CommandParser };
/// Configure the parser
let parser = Parser::former()
.command_prefix( '.' )
.prop_delimeter( ':' )
.form();
/// Parse a command from a` string
let raw_command = parser.command( ".command subject_value prop_name:prop_value" )?;In the above example, a Parser object is created and configured to accept commands with a . prefix and : delimiters for properties.
Note that Parser uses CommandParser trait to parse commands from user input( You can also use NamespaceParser to parse namespaces, or ProgramParser to parse programs from string ).
Fields§
§command_prefix: charSymbol that will be interpreted as the beginning of a command
command_delimiter = .
“.command” -> Command( “command” )
prop_delimeter: charSymbol that will be interpreted as a separator for the name and value of the property
prop_delimiter = :
“prop:value” -> ( “prop”, “value” )
namespace_delimeter: Cow<'static, str>String that will be interpreted as a separator for namespaces
namespace_delimiter = “.also”
“< commands1 > .also < commands2 >” -> Namespace( < commands1 > ), Namespace( < commands2 > )