nushell/crates/nu-cli/tests/commands/mod.rs
Leonhard Kipp 5356cb9fbd
Obey precedence rules in which; Fix #2875 (#2885)
* Obay precedence rules in which; Fix #2875

Before which did not obay the precedence of alias before def commands.
Furthermore, `which -a echo` would only report either an alias or a def command or an
internal command with the provided name. Not all.

With this commit applied its fixed :)

Example:
```shell
/home/leo/repos/nushell(fix/which_reports_wrong_usage)> def echo [] {^echo hi}
/home/leo/repos/nushell(fix/which_reports_wrong_usage)> echo
hi
/home/leo/repos/nushell(fix/which_reports_wrong_usage)> which -a echo
───┬──────┬──────────────────────────┬─────────
 # │ arg  │           path           │ builtin
───┼──────┼──────────────────────────┼─────────
 0 │ echo │ Nushell custom command   │ No
 1 │ echo │ Nushell built-in command │ Yes
 2 │ echo │ /usr/bin/echo            │ No
───┴──────┴──────────────────────────┴─────────
/home/leo/repos/nushell(fix/which_reports_wrong_usage)> alias echo = ^echo hi there
/home/leo/repos/nushell(fix/which_reports_wrong_usage)> echo
hi there
/home/leo/repos/nushell(fix/which_reports_wrong_usage)> which -a echo
───┬──────┬──────────────────────────┬─────────
 # │ arg  │           path           │ builtin
───┼──────┼──────────────────────────┼─────────
 0 │ echo │ Nushell alias            │ No
 1 │ echo │ Nushell custom command   │ No
 2 │ echo │ Nushell built-in command │ Yes
 3 │ echo │ /usr/bin/echo            │ No
───┴──────┴──────────────────────────┴─────────
```

* Fix clippy lint

* Fix vec always Some even if empty
2021-01-09 06:44:31 +13:00

62 lines
714 B
Rust

mod append;
mod autoenv;
mod autoenv_trust;
mod autoenv_untrust;
mod cal;
mod cd;
mod compact;
mod count;
mod cp;
mod def;
mod default;
mod drop;
mod each;
mod echo;
mod empty;
mod enter;
mod every;
mod first;
mod flatten;
mod format;
mod get;
mod group_by;
mod hash_;
mod headers;
mod histogram;
mod insert;
mod into_int;
mod keep;
mod last;
mod lines;
mod ls;
mod math;
mod merge;
mod mkdir;
mod move_;
mod open;
mod parse;
mod path;
mod prepend;
mod random;
mod range;
mod reduce;
mod rename;
mod reverse;
mod rm;
mod save;
mod select;
mod semicolon;
mod skip;
mod sort_by;
mod split_by;
mod split_column;
mod split_row;
mod str_;
mod touch;
mod uniq;
mod update;
mod where_;
mod which;
mod with_env;
mod wrap;