Struct commands::parser::CommandNode
[−]
[src]
pub struct CommandNode { pub node: TreeNode, pub handler: Option<fn(_: &Node)>, pub parameters: Vec<Rc<Node>>, pub wrapped_root: Option<Rc<Node>>, }
A node representing a command. Constructed via Command
and CommandTree
.
If wrapped_root
is set then this node wraps another command.
This is used for the help command so that it can complete
normal commands. The successors
will be those of the wrapped node.
Fields
node: TreeNode
TreeNode
data.
handler: Option<fn(_: &Node)>
The handler which is executed once this node has been accepted.
parameters: Vec<Rc<Node>>
Parameter nodes for this command
wrapped_root: Option<Rc<Node>>
If present, the command wrapped by this node.
Methods
impl CommandNode
[src]
fn new(
name: &str,
help_text: Option<&str>,
hidden: bool,
priority: i32,
successors: Vec<Rc<Node>>,
handler: Option<fn(_: &Node)>,
parameters: Vec<Rc<Node>>
) -> Self
name: &str,
help_text: Option<&str>,
hidden: bool,
priority: i32,
successors: Vec<Rc<Node>>,
handler: Option<fn(_: &Node)>,
parameters: Vec<Rc<Node>>
) -> Self
Construct a new CommandNode
.
Trait Implementations
impl NodeOps for CommandNode
[src]
fn accept<'text>(
&self,
parser: &mut Parser<'text>,
_token: Token,
node_ref: &Rc<Node>
)
&self,
parser: &mut Parser<'text>,
_token: Token,
node_ref: &Rc<Node>
)
Record this command.
fn acceptable(&self, parser: &Parser, node_ref: &Rc<Node>) -> bool
Can this node be accepted in the current parser state? By default, a node can be accepted when it hasn't been seen yet. Read more
fn complete<'text>(&self, token: Option<Token<'text>>) -> Completion<'text>
Given a node and an optional token, provide the completion options. Read more
fn matches(&self, _parser: &Parser, token: Token) -> bool
By default, a node matches a token
when the name of the node starts with the token
. Read more