mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 20:57:49 +02:00
Refactor: introduce 2 associated functions to PipelineData
(#16233)
# Description As title: this pr is try to introduce 2 functions to `PipelineData`: 1. PipelineData::list_stream --> create a PipelineData::ListStream 2. PipelineData::byte_stream -> create a PipelineData::ByteStream And use these functions everywhere. ### Reason behind this change I tried to implement `pipefail` feature, but this would required to change `PipelineData` from enum to struct. So use these functions can reduce diff if I finally change to struct. [Discord message here](https://discord.com/channels/601130461678272522/615962413203718156/1396999539000479784) is my plan. # User-Facing Changes NaN # Tests + Formatting NaN # After Submitting NaN
This commit is contained in:
@ -157,12 +157,12 @@ impl Command for Do {
|
||||
if !stderr_msg.is_empty() {
|
||||
child.stderr = Some(ChildPipe::Tee(Box::new(Cursor::new(stderr_msg))));
|
||||
}
|
||||
Ok(PipelineData::ByteStream(
|
||||
Ok(PipelineData::byte_stream(
|
||||
ByteStream::child(child, span),
|
||||
metadata,
|
||||
))
|
||||
}
|
||||
Err(stream) => Ok(PipelineData::ByteStream(stream, metadata)),
|
||||
Err(stream) => Ok(PipelineData::byte_stream(stream, metadata)),
|
||||
}
|
||||
}
|
||||
Ok(PipelineData::ByteStream(mut stream, metadata))
|
||||
@ -176,7 +176,7 @@ impl Command for Do {
|
||||
if let ByteStreamSource::Child(child) = stream.source_mut() {
|
||||
child.ignore_error(true);
|
||||
}
|
||||
Ok(PipelineData::ByteStream(stream, metadata))
|
||||
Ok(PipelineData::byte_stream(stream, metadata))
|
||||
}
|
||||
Ok(PipelineData::Value(Value::Error { .. }, ..)) | Err(_) if ignore_all_errors => {
|
||||
Ok(PipelineData::empty())
|
||||
@ -189,7 +189,7 @@ impl Command for Do {
|
||||
value
|
||||
}
|
||||
});
|
||||
Ok(PipelineData::ListStream(stream, metadata))
|
||||
Ok(PipelineData::list_stream(stream, metadata))
|
||||
}
|
||||
r => r,
|
||||
}
|
||||
|
Reference in New Issue
Block a user