forked from extern/nushell
First step (#411)
This commit is contained in:
@ -2,8 +2,8 @@ use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type,
|
||||
Value, ValueStream,
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
|
||||
ValueStream,
|
||||
};
|
||||
use regex::Regex;
|
||||
|
||||
@ -117,11 +117,11 @@ fn operate(
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
return Err(ShellError::PipelineMismatch {
|
||||
expected: Type::String,
|
||||
expected_span: head,
|
||||
origin: v.span()?,
|
||||
})
|
||||
return Err(ShellError::PipelineMismatch(
|
||||
"string".into(),
|
||||
head,
|
||||
v.span()?,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value};
|
||||
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Size;
|
||||
@ -110,11 +110,7 @@ fn size(
|
||||
move |v| match v.as_string() {
|
||||
Ok(s) => count(&s, span),
|
||||
Err(_) => Value::Error {
|
||||
error: ShellError::PipelineMismatch {
|
||||
expected: Type::String,
|
||||
expected_span: span,
|
||||
origin: span,
|
||||
},
|
||||
error: ShellError::PipelineMismatch("string".into(), span, span),
|
||||
},
|
||||
},
|
||||
engine_state.ctrlc.clone(),
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -72,11 +72,7 @@ fn split_chars_helper(v: &Value, name: Span) -> Vec<Value> {
|
||||
.collect()
|
||||
} else {
|
||||
vec![Value::Error {
|
||||
error: ShellError::PipelineMismatch {
|
||||
expected: Type::String,
|
||||
expected_span: name,
|
||||
origin: v_span,
|
||||
},
|
||||
error: ShellError::PipelineMismatch("string".into(), name, v_span),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::CallExt;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
|
||||
Category, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -107,11 +107,7 @@ fn split_column_helper(
|
||||
} else {
|
||||
match v.span() {
|
||||
Ok(span) => vec![Value::Error {
|
||||
error: ShellError::PipelineMismatch {
|
||||
expected: Type::String,
|
||||
expected_span: head,
|
||||
origin: span,
|
||||
},
|
||||
error: ShellError::PipelineMismatch("string".into(), head, span),
|
||||
}],
|
||||
Err(error) => vec![Value::Error { error }],
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::CallExt;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
|
||||
Category, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -69,11 +69,7 @@ fn split_row_helper(v: &Value, separator: &Spanned<String>, name: Span) -> Vec<V
|
||||
.collect()
|
||||
} else {
|
||||
vec![Value::Error {
|
||||
error: ShellError::PipelineMismatch {
|
||||
expected: Type::String,
|
||||
expected_span: name,
|
||||
origin: v_span,
|
||||
},
|
||||
error: ShellError::PipelineMismatch("string".into(), name, v_span),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user