Add :doc interpreter directive

This commit is contained in:
greg 2018-09-21 19:25:58 -07:00
parent 1abbe2e448
commit 92078ef7d8
2 changed files with 7 additions and 0 deletions

View File

@ -156,6 +156,9 @@ pub trait ProgrammingLanguageInterface {
fn custom_interpreter_directives_help(&self) -> String { fn custom_interpreter_directives_help(&self) -> String {
format!(">> No custom interpreter directives specified <<") format!(">> No custom interpreter directives specified <<")
} }
fn get_doc(&mut self, _commands: &Vec<&str>) -> Option<String> {
None
}
} }
/* a pass_chain function signature looks like: /* a pass_chain function signature looks like:

View File

@ -361,6 +361,7 @@ impl Repl {
CommandTree::term("prev", None), CommandTree::term("prev", None),
CommandTree::NonTerminal(format!("go"), vec![], None)//TODO CommandTree::NonTerminal(format!("go"), vec![], None)//TODO
], Some(format!("switch between languages, or go directly to a langauge by name"))), ], Some(format!("switch between languages, or go directly to a langauge by name"))),
CommandTree::term("doc", Some("Get language-specific help for an item")),
]) ])
} }
@ -437,6 +438,9 @@ impl Repl {
Some(buf) Some(buf)
}, },
"debug" => self.handle_debug(commands), "debug" => self.handle_debug(commands),
"doc" => self.languages[self.current_language_index]
.get_doc(&commands)
.or(Some(format!("No docs implemented"))),
e => self.languages[self.current_language_index] e => self.languages[self.current_language_index]
.handle_custom_interpreter_directives(&commands) .handle_custom_interpreter_directives(&commands)
.or(Some(format!("Unknown command: {}", e))) .or(Some(format!("Unknown command: {}", e)))