Improve external output in subexprs (#294)

This commit is contained in:
JT
2021-11-06 18:50:33 +13:00
committed by GitHub
parent c7d159a0f3
commit 02b8027749
50 changed files with 320 additions and 136 deletions

View File

@ -39,7 +39,13 @@ impl Command for Benchmark {
let mut stack = stack.collect_captures(&block.captures);
let start_time = Instant::now();
eval_block(engine_state, &mut stack, block, PipelineData::new())?.into_value();
eval_block(
engine_state,
&mut stack,
block,
PipelineData::new(call.head),
)?
.into_value(call.head);
let end_time = Instant::now();

View File

@ -161,9 +161,9 @@ impl ExternalCommand {
});
// The ValueStream is consumed by the next expression in the pipeline
ChannelReceiver::new(rx).into_pipeline_data(ctrlc)
ChannelReceiver::new(rx, self.name.span).into_pipeline_data(ctrlc)
} else {
PipelineData::new()
PipelineData::new(self.name.span)
};
match child.wait() {
@ -214,11 +214,12 @@ enum Data {
// It implements iterator so it can be used as a ValueStream
struct ChannelReceiver {
rx: mpsc::Receiver<Data>,
span: Span,
}
impl ChannelReceiver {
pub fn new(rx: mpsc::Receiver<Data>) -> Self {
Self { rx }
pub fn new(rx: mpsc::Receiver<Data>, span: Span) -> Self {
Self { rx, span }
}
}
@ -230,11 +231,11 @@ impl Iterator for ChannelReceiver {
Ok(v) => match v {
Data::String(s) => Some(Value::String {
val: s,
span: Span::unknown(),
span: self.span,
}),
Data::Bytes(b) => Some(Value::Binary {
val: b,
span: Span::unknown(),
span: self.span,
}),
},
Err(_) => None,