Initial debug-handler function

This commit is contained in:
greg 2019-03-26 19:55:47 -07:00
parent 004b056232
commit a829fb6cd8
2 changed files with 11 additions and 8 deletions

View File

@ -23,8 +23,8 @@ impl CommandTree {
CommandTree::NonTerminal {name: s.to_string(), help_msg: help.map(|x| x.to_string()), children: vec![] }
}
pub fn term_with_function(s: &str, help: Option<&str>, function: BoxedCommandFunction) -> CommandTree {
CommandTree::Terminal {name: s.to_string(), help_msg: help.map(|x| x.to_string()), function, children: vec![] }
pub fn term_with_function(s: &str, help: Option<&str>, children: Vec<CommandTree>, function: BoxedCommandFunction) -> CommandTree {
CommandTree::Terminal {name: s.to_string(), help_msg: help.map(|x| x.to_string()), function, children }
}
pub fn nonterm(s: &str, help: Option<&str>, children: Vec<CommandTree>) -> CommandTree {

View File

@ -201,21 +201,21 @@ impl Repl {
.collect();
CommandTree::Top(vec![
CommandTree::term_with_function("exit", Some("exit the REPL"), Box::new(|repl: &mut Repl, _cmds: &[&str]| {
CommandTree::term_with_function("exit", Some("exit the REPL"), vec![], Box::new(|repl: &mut Repl, _cmds: &[&str]| {
repl.save_before_exit();
::std::process::exit(0)
})),
CommandTree::term_with_function("quit", Some("exit the REPL"), Box::new(|repl: &mut Repl, _cmds: &[&str]| {
CommandTree::term_with_function("quit", Some("exit the REPL"), vec![], Box::new(|repl: &mut Repl, _cmds: &[&str]| {
repl.save_before_exit();
::std::process::exit(0)
})),
CommandTree::term_with_function("help", Some("Print this help message"), Box::new(|repl: &mut Repl, cmds: &[&str]| {
CommandTree::term_with_function("help", Some("Print this help message"), vec![], Box::new(|repl: &mut Repl, cmds: &[&str]| {
Some(repl.print_help_message(cmds))
})),
CommandTree::nonterm("debug",
CommandTree::term_with_function("debug",
Some("Configure debug information"),
vec![
CommandTree::term_with_function("list-passes", Some("List all registered compiler passes"), Box::new(|repl: &mut Repl, cmds: &[&str]| {
CommandTree::term_with_function("list-passes", Some("List all registered compiler passes"), vec![], Box::new(|repl: &mut Repl, cmds: &[&str]| {
let language_state = repl.get_cur_language_state();
let pass_names = match language_state.request_meta(LangMetaRequest::StageNames) {
LangMetaResponse::StageNames(names) => names,
@ -237,7 +237,10 @@ impl Repl {
CommandTree::nonterm_no_further_tab_completions("on", None),
CommandTree::nonterm_no_further_tab_completions("off", None),
])
]
],
Box::new(|repl: &mut Repl, cmds: &[&str]| {
Some(format!("Commands: {:?}", cmds))
})
),
CommandTree::nonterm("lang",
Some("switch between languages, or go directly to a langauge by name"),