nushell/crates/nu-cli/src
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
..
commands Obey precedence rules in which; Fix #2875 (#2885) 2021-01-09 06:44:31 +13:00
completion Document lexer (#2865) 2021-01-07 16:03:00 +13:00
env Multiline scripts part 2 (#2795) 2020-12-18 20:53:49 +13:00
evaluate Obey precedence rules in which; Fix #2875 (#2885) 2021-01-09 06:44:31 +13:00
shell Rename the Path and Pattern primitives (#2889) 2021-01-08 20:30:41 +13:00
types Rename the Path and Pattern primitives (#2889) 2021-01-08 20:30:41 +13:00
utils Consolidate suggestions code (#2597) 2020-09-25 15:44:24 +12:00
cli.rs Treat all the startup commands as a single script file (#2890) 2021-01-08 19:36:31 +13:00
commands.rs rename set/set-env to let/let-env (#2859) 2021-01-05 12:30:55 +13:00
deserializer.rs Rename the Path and Pattern primitives (#2889) 2021-01-08 20:30:41 +13:00
documentation.rs Multiline scripts part 2 (#2795) 2020-12-18 20:53:49 +13:00
env.rs WIP: Per directory env-variables (#1943) 2020-06-08 19:55:25 +12:00
evaluation_context.rs Improve some errors, streamline internal error handling (#2839) 2021-01-02 08:52:19 +13:00
examples.rs Document lexer (#2865) 2021-01-07 16:03:00 +13:00
format.rs Nu table (#2015) 2020-06-20 15:41:53 +12:00
futures.rs Move most of the root package into a subcrate. (#1445) 2020-03-04 13:58:20 -05:00
git.rs Bump to 0.18.2. Move starship external. (#2345) 2020-08-14 07:02:45 +12:00
keybinding.rs Revert "Bump Rustyline to 7.0.0 (#2776)" (#2778) 2020-12-05 17:12:42 +13:00
lib.rs nucli refactor: move rustyline and ctrlc features in cli.rs to line_editor.rs (#2854) 2021-01-07 06:47:36 +13:00
line_editor.rs nucli refactor: move rustyline and ctrlc features in cli.rs to line_editor.rs (#2854) 2021-01-07 06:47:36 +13:00
path.rs Changing the directory to '.' doesn't modify the prompt anymore (#2457) 2020-08-31 05:24:38 +12:00
plugin.rs Fix new clippy warnings (#2760) 2020-11-22 13:37:16 +13:00
prelude.rs Nucli refactor script mod (#2831) 2020-12-31 12:38:31 +13:00
script.rs Fix typos (#2842) 2021-01-02 17:24:32 +13:00
shell.rs Update rustyline to latest (#2565) 2020-09-17 18:02:30 +12:00
types.rs Change alias shape inference to proposal of RFC#4 (#2685) 2020-10-29 06:49:38 +13:00
utils.rs Consolidate suggestions code (#2597) 2020-09-25 15:44:24 +12:00