Add nonterminal with function

For making tab completion work properly
This commit is contained in:
greg 2019-03-19 04:28:54 -07:00
parent 9e58e3d7de
commit 4319c802f5
1 changed files with 11 additions and 0 deletions

View File

@ -13,6 +13,7 @@ pub enum CommandTree {
name: String,
children: Vec<CommandTree>,
help_msg: Option<String>,
function: Option<BoxedCommandFunction>,
},
Top(Vec<CommandTree>),
}
@ -31,6 +32,16 @@ impl CommandTree {
name: s.to_string(),
help_msg: help.map(|x| x.to_string()),
children,
function: None,
}
}
pub fn nonterm_with_function(s: &str, help: Option<&str>, children: Vec<CommandTree>, func: BoxedCommandFunction) -> CommandTree {
CommandTree::NonTerminal {
name: s.to_string(),
help_msg: help.map(|x| x.to_string()),
children,
function: Some(func),
}
}