add module name to $nu.scope.commands info (#4877)

This commit is contained in:
Darren Schroeder 2022-03-19 10:58:56 -05:00 committed by GitHub
parent 01c1e5e8b0
commit 285f91e67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -794,12 +794,27 @@ pub fn create_scope(
let mut cols = vec![]; let mut cols = vec![];
let mut vals = vec![]; let mut vals = vec![];
let mut overlay_commands = vec![];
for overlay in &overlays_map {
let overlay_name = String::from_utf8_lossy(*overlay.0).to_string();
let overlay_id = engine_state.find_overlay(*overlay.0);
if let Some(overlay_id) = overlay_id {
let overlay = engine_state.get_overlay(overlay_id);
if overlay.has_decl(command_name) {
overlay_commands.push(overlay_name);
}
}
}
cols.push("command".into()); cols.push("command".into());
vals.push(Value::String { vals.push(Value::String {
val: String::from_utf8_lossy(command_name).to_string(), val: String::from_utf8_lossy(command_name).to_string(),
span, span,
}); });
cols.push("module_name".into());
vals.push(Value::string(overlay_commands.join(", "), span));
let decl = engine_state.get_decl(*decl_id); let decl = engine_state.get_decl(*decl_id);
let signature = decl.signature(); let signature = decl.signature();
cols.push("category".to_string()); cols.push("category".to_string());