diff --git a/schala-repl/src/repl/directives.rs b/schala-repl/src/repl/directives.rs index 1463c86..06de3c9 100644 --- a/schala-repl/src/repl/directives.rs +++ b/schala-repl/src/repl/directives.rs @@ -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) -> CommandTree { - use DirectiveAction::*; - let passes_directives: Vec = 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, include_help: bool) -> Vec { + 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) -> CommandTree { ] ), CommandTree::terminal("doc", Some("Get language-specific help for an item"), vec![], Doc), - ]) + ] } -