mirror of
https://github.com/nushell/nushell.git
synced 2025-07-04 08:31:05 +02:00
Introduce metadata into the pipeline (#397)
This commit is contained in:
@ -34,19 +34,22 @@ impl Command for Echo {
|
||||
let n = to_be_echoed.len();
|
||||
match n.cmp(&1usize) {
|
||||
// More than one value is converted in a stream of values
|
||||
std::cmp::Ordering::Greater => PipelineData::Stream(ValueStream::from_stream(
|
||||
to_be_echoed.into_iter(),
|
||||
engine_state.ctrlc.clone(),
|
||||
)),
|
||||
std::cmp::Ordering::Greater => PipelineData::Stream(
|
||||
ValueStream::from_stream(to_be_echoed.into_iter(), engine_state.ctrlc.clone()),
|
||||
None,
|
||||
),
|
||||
|
||||
// But a single value can be forwarded as it is
|
||||
std::cmp::Ordering::Equal => PipelineData::Value(to_be_echoed[0].clone()),
|
||||
std::cmp::Ordering::Equal => PipelineData::Value(to_be_echoed[0].clone(), None),
|
||||
|
||||
// When there are no elements, we echo the empty string
|
||||
std::cmp::Ordering::Less => PipelineData::Value(Value::String {
|
||||
val: "".to_string(),
|
||||
span: call.head,
|
||||
}),
|
||||
std::cmp::Ordering::Less => PipelineData::Value(
|
||||
Value::String {
|
||||
val: "".to_string(),
|
||||
span: call.head,
|
||||
},
|
||||
None,
|
||||
),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user