Remove required positional arguments from run-external and exec#14765
Remove required positional arguments from run-external and exec#14765WindSoilder merged 6 commits intonushell:mainfrom
run-external and exec#14765Conversation
|
Actually wait, this isn't a breaking change. I'm not sure why I thought it was. The old format still works in the after the PR, since it's still just rest arguments. let command = ["cat" "hello.txt"]
run-external ...$command
# => hello world!
run-external ($command | first) ...($command | skip 1)
# => hello world! |
|
I added test permutations in Additionally, I pulled in a new dependency to help with these tests, |
| .input_output_types(vec![(Type::Any, Type::Any)]) | ||
| .required( | ||
| "command", | ||
| SyntaxShape::OneOf(vec![SyntaxShape::GlobPattern, SyntaxShape::String]), |
There was a problem hiding this comment.
To be honest I'm little worry about changing from SyntaxShape::String to SyntaxShape::Any.
However, I don't have a clue how it's going to work internally.
There was a problem hiding this comment.
I think it should just turn these parse errors into runtime errors, but I'll test it out
There was a problem hiding this comment.
It seems like putting literals for most types in the command position just attempt to run that literal as a command anyways, which is fine. If it can't be coerced into a string it will simply error at runtime. The only difference I found was bools:
Before:
$ run-external false
Error: nu::parser::parse_mismatch_with_full_string_msg
× Parse mismatch during operation.
╭─[entry #18:1:14]
1 │ run-external false
· ──┬──
· ╰── expected one of a list of accepted shapes: [GlobPattern, String]
╰────
After:
run-external false
(runs false executable)
Seems like the after behavior is preferable here.
Description
This PR removes the required positional argument from
run-externalandexecin favor of the rest arguments, meaning lists of external commands can be spread directly intorun-externalandexec. This does have the drawback of making callingrun-externalandexecwith no arguments a run-time error rather than a parse error, but I don't imagine that is an issue.Before (for both
run-externalandexec):After (for both
run-externalandexec):User-Facing Changes
Lists can now be spread directly into
run-externalandexec:Tests + Formatting
toolkit fmttoolkit clippytoolkit testtoolkit test stdlibAfter Submitting
N/A