diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index 9eb1924..442e58a 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -310,7 +310,17 @@ impl Repl { CommandTree::nonterm("go", None, vec![]), ] ), - CommandTree::nonterm_no_further_tab_completions("doc", Some("Get language-specific help for an item")), + CommandTree::term_with_function("doc", Some("Get language-specific help for an item"), vec![], Box::new(|repl: &mut Repl, cmds: &[&str]| { + cmds.get(0).map(|cmd| { + let source = cmd.to_string(); + let meta = LangMetaRequest::Docs { source }; + let cur_state = repl.get_cur_language_state(); + match cur_state.request_meta(meta) { + LangMetaResponse::Docs { doc_string } => Some(doc_string), + _ => Some(format!("Invalid doc response")) + } + }).unwrap_or(Some(format!(":docs needs an argument"))) + })) ]) } }