Tab completion for help

This commit is contained in:
greg 2019-06-05 02:48:45 -07:00
parent 6fb9b4c2d3
commit 376fa1d1d1

View File

@ -2,16 +2,19 @@ use crate::repl::command_tree::CommandTree;
use crate::repl::directive_actions::DirectiveAction;
pub fn directives_from_pass_names(pass_names: &Vec<String>) -> CommandTree {
use DirectiveAction::*;
let passes_directives: Vec<CommandTree> = pass_names.iter()
.map(|pass_name| { CommandTree::nonterm_no_further_tab_completions(pass_name, None) })
.collect();
CommandTree::Top(get_list(&passes_directives, true))
}
CommandTree::Top(vec![
fn get_list(passes_directives: &Vec<CommandTree>, include_help: bool) -> Vec<CommandTree> {
use DirectiveAction::*;
vec![
CommandTree::terminal("exit", Some("exit the REPL"), vec![], QuitProgram),
CommandTree::terminal("quit", Some("exit the REPL"), vec![], QuitProgram),
CommandTree::terminal("help", Some("Print this help message"), vec![], Help),
CommandTree::terminal("help", Some("Print this help message"), if include_help { get_list(passes_directives, false) } else { vec![] }, Help),
CommandTree::nonterm("debug",
Some("Configure debug information"),
vec![
@ -38,6 +41,5 @@ pub fn directives_from_pass_names(pass_names: &Vec<String>) -> CommandTree {
]
),
CommandTree::terminal("doc", Some("Get language-specific help for an item"), vec![], Doc),
])
]
}