forked from extern/nushell
Reworking help aliases
(#8372)
This commit is contained in:
parent
3e9bb4028a
commit
0ff1cb1ea6
@ -1,7 +1,8 @@
|
|||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::{EngineState, Stack, Visibility},
|
engine::{Command, EngineState, Stack, Visibility},
|
||||||
ShellError, Signature, Span, SyntaxShape, Type, Value,
|
ShellError, Signature, Span, SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
use std::borrow::Borrow;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@ -494,6 +495,36 @@ impl<'e, 's> ScopeData<'e, 's> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (name_bytes, decl_id) in self.engine_state.get_decls_sorted(false) {
|
||||||
|
if self.visibility.is_decl_id_visible(&decl_id) {
|
||||||
|
let decl = self.engine_state.get_decl(decl_id);
|
||||||
|
if let Some(alias) = decl.as_alias() {
|
||||||
|
let name = String::from_utf8_lossy(&name_bytes).to_string();
|
||||||
|
let sig = decl.signature().update_from_command(name, decl.borrow());
|
||||||
|
let key = sig.name;
|
||||||
|
|
||||||
|
aliases.push(Value::Record {
|
||||||
|
cols: vec!["name".into(), "expansion".into(), "usage".into()],
|
||||||
|
vals: vec![
|
||||||
|
Value::String { val: key, span },
|
||||||
|
Value::String {
|
||||||
|
val: String::from_utf8_lossy(
|
||||||
|
self.engine_state
|
||||||
|
.get_span_contents(&alias.wrapped_call.span),
|
||||||
|
)
|
||||||
|
.to_string(),
|
||||||
|
span,
|
||||||
|
},
|
||||||
|
Value::String {
|
||||||
|
val: alias.signature().usage,
|
||||||
|
span,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
span,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aliases.sort_by(|a, b| a.partial_cmp(b).unwrap_or(Ordering::Equal));
|
aliases.sort_by(|a, b| a.partial_cmp(b).unwrap_or(Ordering::Equal));
|
||||||
aliases
|
aliases
|
||||||
|
Loading…
Reference in New Issue
Block a user