Repository navigation
fix(which): remove required positional argument to allow spread input - #15870
Conversation
sholderbach
left a comment
There was a problem hiding this comment.
Thank you for tackling this!
| Signature::build("which") | ||
| .input_output_types(vec![(Type::Nothing, Type::table())]) | ||
| .allow_variants_without_examples(true) | ||
| .required("application", SyntaxShape::String, "Application.") |
There was a problem hiding this comment.
Can you update the documentation on rest to reflect something like Application(s).
There was a problem hiding this comment.
Thanks for the suggestion! I've updated the doc and pushed the changes. Let me know if anything else needs tweaking.
| } | ||
|
|
||
| #[test] | ||
| fn which_accepts_splatted_list() { |
There was a problem hiding this comment.
Nit: for consistency as we refer to it as the spread operator.
| fn which_accepts_splatted_list() { | |
| fn which_accepts_spread_list() { |
|
@sholderbach fixed the issue should pass now. |
|
@sholderbach my local tests are passing without any issues, is there something I am missing here? |
sholderbach
left a comment
There was a problem hiding this comment.
We recently encountered some issues with this unrelated commands::job::killing_job_kills_pids test being flaky. Not your problem to worry about here. Started a rerun, should resolve.
Summary
This PR removes the required positional argument from the
whichcommand, allowing it to accept input via the spread (...) operator. This enables expressions like:Previously, this failed due to a missing required positional argument. The Nushell runtime already handles empty input gracefully, so the change aligns with existing behavior.
Motivation
Making
whichcompatible with splatted input improves composability and aligns with user expectations in scriptable environments. It supports patterns where the input may be constructed dynamically or piped in from earlier commands.Changes
requiredattribute from the positional argument in thewhichcommand signature.Examples
Before
After
Testing
cargo test --allandcargo test -p nu-commandwhichcommandRelated Issues
Closes [#15801](#15801)