mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 15:38:55 +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:
@@ -88,8 +88,8 @@ impl Command for Explore {
|
||||
let result = run_pager(engine_state, &mut stack.clone(), input, config);
|
||||
|
||||
match result {
|
||||
Ok(Some(value)) => Ok(PipelineData::Value(value, None)),
|
||||
Ok(None) => Ok(PipelineData::Value(Value::default(), None)),
|
||||
Ok(Some(value)) => Ok(PipelineData::value(value, None)),
|
||||
Ok(None) => Ok(PipelineData::value(Value::default(), None)),
|
||||
Err(err) => {
|
||||
let shell_error = match err.downcast::<ShellError>() {
|
||||
Ok(e) => e,
|
||||
@@ -102,7 +102,7 @@ impl Command for Explore {
|
||||
},
|
||||
};
|
||||
|
||||
Ok(PipelineData::Value(
|
||||
Ok(PipelineData::value(
|
||||
Value::error(shell_error, call.head),
|
||||
None,
|
||||
))
|
||||
|
@@ -23,7 +23,7 @@ pub fn run_command_with_value(
|
||||
});
|
||||
}
|
||||
|
||||
let pipeline = PipelineData::Value(input.clone(), None);
|
||||
let pipeline = PipelineData::value(input.clone(), None);
|
||||
let pipeline = run_nu_command(engine_state, stack, command, pipeline)?;
|
||||
if let PipelineData::Value(Value::Error { error, .. }, ..) = pipeline {
|
||||
Err(ShellError::GenericError {
|
||||
|
Reference in New Issue
Block a user