forked from extern/nushell
collect
: don't require a closure (#12788)
# 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?
This commit is contained in:
@ -245,11 +245,15 @@ impl Command for Save {
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
input => {
|
||||
check_saving_to_source_file(
|
||||
input.metadata().as_ref(),
|
||||
&path,
|
||||
stderr_path.as_ref(),
|
||||
)?;
|
||||
// It's not necessary to check if we are saving to the same file if this is a
|
||||
// collected value, and not a stream
|
||||
if !matches!(input, PipelineData::Value(..) | PipelineData::Empty) {
|
||||
check_saving_to_source_file(
|
||||
input.metadata().as_ref(),
|
||||
&path,
|
||||
stderr_path.as_ref(),
|
||||
)?;
|
||||
}
|
||||
|
||||
let bytes =
|
||||
input_to_bytes(input, Path::new(&path.item), raw, engine_state, stack, span)?;
|
||||
|
Reference in New Issue
Block a user