nushell/crates/nu-protocol/src
Devyn Cairns 01891d637d
Make parsing for unknown args in known externals like normal external calls (#13414)
# Description

This corrects the parsing of unknown arguments provided to known
externals to behave exactly like external arguments passed to normal
external calls.

I've done this by adding a `SyntaxShape::ExternalArgument` which
triggers the same parsing rules.

Because I didn't like how the highlighting looked, I modified the
flattener to emit `ExternalArg` flat shapes for arguments that have that
syntax shape and are plain strings/globs. This is the same behavior that
external calls have.

Aside from passing the tests, I've also checked manually that the
completer seems to work adequately. I can confirm that specified
positional arguments get completion according to their specified type
(including custom completions), and then anything remaining gets
filepath style completion, as you'd expect from an external command.

Thanks to @OJarrisonn for originally finding this issue.

# User-Facing Changes

- Unknown args are now parsed according to their specified syntax shape,
rather than `Any`. This may be a breaking change, though I think it's
extremely unlikely in practice.
- The unspecified arguments of known externals are now highlighted /
flattened identically to normal external arguments, which makes it more
clear how they're being interpreted, and should help the completer
function properly.
- Known externals now have an implicit rest arg if not specified named
`args`, with a syntax shape of `ExternalArgument`.

# Tests + Formatting
Tests added for the new behaviour. Some old tests had to be corrected to
match.

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
- [ ] release notes (bugfix, and debatable whether it's a breaking
change)
2024-07-21 01:32:36 -07:00
..
ast Make ast::Call::span() and arguments_span() more robust (#13412) 2024-07-19 05:12:19 -07:00
config Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
debugger Overhaul $in expressions (#13357) 2024-07-17 16:02:42 -05:00
engine Remove unused field in StateWorkingSet (#13387) 2024-07-16 11:28:31 +02:00
errors Deprecate group in favor of chunks (#13377) 2024-07-16 03:49:00 +00:00
ir Make plugins able to find and call other commands (#13407) 2024-07-19 13:54:21 +08:00
pipeline Deprecate group in favor of chunks (#13377) 2024-07-16 03:49:00 +00:00
plugin remove the deprecated register command (#13297) 2024-07-05 07:16:50 -05:00
process Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
value Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
alias.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
did_you_mean.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
eval_base.rs Overhaul $in expressions (#13357) 2024-07-17 16:02:42 -05:00
eval_const.rs Use directories for autoloading (#13382) 2024-07-19 03:47:07 -07:00
example.rs Overhaul the plugin cache file with a new msgpack+brotli format (#12579) 2024-04-21 07:36:26 -05:00
id.rs Internal representation (IR) compiler and evaluator (#13330) 2024-07-10 17:33:59 -07:00
lev_distance.rs Rework for new clippy lints (#12736) 2024-05-02 19:29:03 +02:00
lib.rs Add top-level crate documentation/READMEs (#12907) 2024-07-14 10:10:41 +02:00
module.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
parser_path.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
signature.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
span.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
syntax_shape.rs Make parsing for unknown args in known externals like normal external calls (#13414) 2024-07-21 01:32:36 -07:00
ty.rs Deprecate group in favor of chunks (#13377) 2024-07-16 03:49:00 +00:00