Hook up docs

This commit is contained in:
greg 2019-05-17 18:23:03 -07:00
parent 94ea7bcd09
commit ffdae14a88

View File

@ -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")))
}))
])
}
}