This commit is contained in:
JT
2021-10-25 17:24:10 +13:00
parent b6d269e90a
commit 397a31e69c
8 changed files with 241 additions and 195 deletions

View File

@ -1,4 +1,4 @@
use crate::{Span, Value, ValueStream};
use crate::{ast::PathMember, ShellError, Span, Value, ValueStream};
pub enum PipelineData {
Value(Value),
@ -19,6 +19,25 @@ impl PipelineData {
},
}
}
pub fn collect_string(self) -> String {
match self {
PipelineData::Value(v) => v.collect_string(),
PipelineData::Stream(s) => s.collect_string(),
}
}
pub fn follow_cell_path(self, cell_path: &[PathMember]) -> Result<Value, ShellError> {
match self {
// FIXME: there are probably better ways of doing this
PipelineData::Stream(stream) => Value::List {
vals: stream.collect(),
span: Span::unknown(),
}
.follow_cell_path(cell_path),
PipelineData::Value(v) => v.follow_cell_path(cell_path),
}
}
}
impl Default for PipelineData {