Add helper functions
This commit is contained in:
parent
3d1145e759
commit
8dfa500c80
|
@ -635,6 +635,34 @@ impl PipelineData {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unsupported_input_error(
|
||||||
|
self,
|
||||||
|
expected_type: impl Into<String>,
|
||||||
|
span: Span,
|
||||||
|
) -> ShellError {
|
||||||
|
match self {
|
||||||
|
PipelineData::Empty => ShellError::PipelineEmpty { dst_span: span },
|
||||||
|
PipelineData::Value(value, ..) => ShellError::OnlySupportsThisInputType {
|
||||||
|
exp_input_type: expected_type.into(),
|
||||||
|
wrong_type: value.get_type().get_non_specified_string(),
|
||||||
|
dst_span: span,
|
||||||
|
src_span: value.span(),
|
||||||
|
},
|
||||||
|
PipelineData::ListStream(stream, ..) => ShellError::OnlySupportsThisInputType {
|
||||||
|
exp_input_type: expected_type.into(),
|
||||||
|
wrong_type: "list (stream)".into(),
|
||||||
|
dst_span: span,
|
||||||
|
src_span: stream.span(),
|
||||||
|
},
|
||||||
|
PipelineData::ByteStream(stream, ..) => ShellError::OnlySupportsThisInputType {
|
||||||
|
exp_input_type: expected_type.into(),
|
||||||
|
wrong_type: stream.type_().describe().into(),
|
||||||
|
dst_span: span,
|
||||||
|
src_span: stream.span(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PipelineIteratorInner {
|
enum PipelineIteratorInner {
|
||||||
|
|
|
@ -36,6 +36,10 @@ pub enum Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type {
|
impl Type {
|
||||||
|
pub fn list(inner: Type) -> Self {
|
||||||
|
Self::List(Box::new(inner))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn record() -> Self {
|
pub fn record() -> Self {
|
||||||
Self::Record([].into())
|
Self::Record([].into())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user