From 4319c802f546973cd375b60144f548444dea7288 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 19 Mar 2019 04:28:54 -0700 Subject: [PATCH] Add nonterminal with function For making tab completion work properly --- schala-repl/src/repl/command_tree.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/schala-repl/src/repl/command_tree.rs b/schala-repl/src/repl/command_tree.rs index 279a338..9832f87 100644 --- a/schala-repl/src/repl/command_tree.rs +++ b/schala-repl/src/repl/command_tree.rs @@ -13,6 +13,7 @@ pub enum CommandTree { name: String, children: Vec, help_msg: Option, + function: Option, }, Top(Vec), } @@ -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, func: BoxedCommandFunction) -> CommandTree { + CommandTree::NonTerminal { + name: s.to_string(), + help_msg: help.map(|x| x.to_string()), + children, + function: Some(func), } }