Add aliased command to which output (#2894)

* Add aliased command to which output

* Fix alias arguments not being displayed
This commit is contained in:
Coen Fox 2021-01-10 04:19:46 +11:00 committed by GitHub
parent 99117ff2ef
commit 363dc51ba0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View file

@ -61,7 +61,21 @@ fn get_entries_in_aliases(scope: &Scope, name: &str, tag: Tag) -> Vec<Value> {
.get_aliases_with_name(name)
.unwrap_or_default()
.into_iter()
.map(|_| create_entry!(name, "Nushell alias", tag.clone(), false))
.map(|spans| {
spans
.into_iter()
.map(|span| span.item)
.collect::<Vec<String>>()
.join(" ")
})
.map(|alias| {
create_entry!(
name,
format!("Nushell alias: {}", alias),
tag.clone(),
false
)
})
.collect::<Vec<_>>();
trace!("Found {} aliases", aliases.len());
aliases

View file

@ -17,7 +17,7 @@ fn which_alias_ls() {
"alias ls = ls -a; which ls | get path | str trim"
);
assert_eq!(actual.out, "Nushell alias");
assert_eq!(actual.out, "Nushell alias: ls -a");
}
#[test]
@ -37,7 +37,7 @@ fn correct_precedence_alias_def_custom() {
"def ls [] {echo def}; alias ls = echo alias; which ls | get path | str trim"
);
assert_eq!(actual.out, "Nushell alias");
assert_eq!(actual.out, "Nushell alias: echo alias");
}
#[test]