Revert "Add support for optional list stream output formatting (#6325)" (#6454)

This reverts commit ec4e3a6d5c.
This commit is contained in:
Darren Schroeder
2022-08-31 18:09:40 -05:00
committed by GitHub
parent 3ec53e544c
commit 4858a9a817
21 changed files with 60 additions and 181 deletions

View File

@ -34,32 +34,28 @@ impl Command for Echo {
call: &Call,
_input: PipelineData,
) -> Result<PipelineData, ShellError> {
call.rest(engine_state, stack, 0)
.map(|to_be_echoed: Vec<Value>| {
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::ListStream(
ListStream::from_stream(
to_be_echoed.into_iter(),
engine_state.ctrlc.clone(),
),
None,
),
call.rest(engine_state, stack, 0).map(|to_be_echoed| {
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::ListStream(
ListStream::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(), None),
// But a single value can be forwarded as it is
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,
},
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,
},
None,
),
}
})
}
fn examples(&self) -> Vec<Example> {

View File

@ -91,7 +91,7 @@ impl Command for For {
Value::List { vals, .. } => {
Ok(ListStream::from_stream(vals.into_iter(), ctrlc.clone())
.enumerate()
.map(move |(idx, (x, _))| {
.map(move |(idx, x)| {
stack.with_env(&orig_env_vars, &orig_env_hidden);
stack.add_var(