-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collect
: don't require a closure
#12788
Conversation
I would be in favor of deprecating the closure arg. We would have to figure out another way to implement the |
I don't think it's a breaking change because it converts from a required parameter to optional parameter, so I will remove the label |
I think we also need to change parser, it uses nushell/crates/nu-parser/src/parser.rs Lines 6241 to 6255 in 92831d7
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To deliver on the promise for the open ... | collect | save ...
round trip we should strip the metadata if it matches DataSource::FilePath
. The others should probably remain if we don't want to commit to this side effect but I would say that DataSource::FilePath
is currently an implementation detail for the particular challenge of inplace modifying a file.
Does this make sense? I changed the |
In my view @IanManske's suggestion is an orthogonal improvement. I think for this PR on open cycle.txt | collect | filter { true } | save cycle.txt |
Okay, I think I've fixed it to be correct. File path metadata is removed on Added a couple tests to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Good additional tests
# Description This changes the `collect` command so that it doesn't require a closure. Still allowed, optionally. Before: ```nushell open foo.json | insert foo bar | collect { save -f foo.json } ``` After: ```nushell open foo.json | insert foo bar | collect | save -f foo.json ``` The closure argument isn't really necessary, as collect values are also supported as `PipelineData`. # User-Facing Changes - `collect` command changed # Tests + Formatting Example changed to reflect. # After Submitting - [ ] release notes - [ ] we may want to deprecate the closure arg?
Description
This changes the
collect
command so that it doesn't require a closure. Still allowed, optionally.Before:
After:
The closure argument isn't really necessary, as collect values are also supported as
PipelineData
.User-Facing Changes
collect
command changedTests + Formatting
Example changed to reflect.
After Submitting