forked from extern/nushell
Move input/output type from Command to Signature (#5880)
This commit is contained in:
@ -2598,10 +2598,10 @@ pub fn parse_register(
|
||||
// the plugin is called to get the signatures or to use the given signature
|
||||
let signature = call.positional_nth(1).map(|expr| {
|
||||
let signature = working_set.get_span_contents(expr.span);
|
||||
serde_json::from_slice::<Signature>(signature).map_err(|_| {
|
||||
serde_json::from_slice::<Signature>(signature).map_err(|e| {
|
||||
ParseError::LabeledError(
|
||||
"Signature deserialization error".into(),
|
||||
"unable to deserialize signature".into(),
|
||||
format!("unable to deserialize signature: {}", e),
|
||||
spans[0],
|
||||
)
|
||||
})
|
||||
|
@ -748,7 +748,7 @@ pub fn parse_internal_call(
|
||||
|
||||
let decl = working_set.get_decl(decl_id);
|
||||
let signature = decl.signature();
|
||||
let output = decl.output_type();
|
||||
let output = signature.output_type.clone();
|
||||
|
||||
working_set.type_scope.add_type(output.clone());
|
||||
|
||||
|
@ -753,7 +753,10 @@ mod input_types {
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("custom".into()))
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Any)
|
||||
.output_type(Type::Custom("custom".into()))
|
||||
.category(Category::Custom("custom".into()))
|
||||
}
|
||||
|
||||
fn run(
|
||||
@ -765,14 +768,6 @@ mod input_types {
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn input_type(&self) -> nu_protocol::Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn output_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -791,6 +786,8 @@ mod input_types {
|
||||
Signature::build(self.name())
|
||||
.required("column", SyntaxShape::String, "column name")
|
||||
.required("other", SyntaxShape::String, "other value")
|
||||
.input_type(Type::Custom("custom".into()))
|
||||
.output_type(Type::Custom("custom".into()))
|
||||
.category(Category::Custom("custom".into()))
|
||||
}
|
||||
|
||||
@ -803,14 +800,6 @@ mod input_types {
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn input_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -828,6 +817,7 @@ mod input_types {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build(self.name())
|
||||
.required("operation", SyntaxShape::String, "operation")
|
||||
.input_type(Type::Custom("custom".into()))
|
||||
.category(Category::Custom("custom".into()))
|
||||
}
|
||||
|
||||
@ -840,10 +830,6 @@ mod input_types {
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn input_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -888,17 +874,11 @@ mod input_types {
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build(self.name())
|
||||
.rest("operation", SyntaxShape::Any, "operation")
|
||||
.input_type(Type::Custom("custom".into()))
|
||||
.output_type(Type::Custom("custom".into()))
|
||||
.category(Category::Custom("custom".into()))
|
||||
}
|
||||
|
||||
fn input_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
@ -923,15 +903,10 @@ mod input_types {
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("custom".into()))
|
||||
}
|
||||
|
||||
fn input_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> nu_protocol::Type {
|
||||
Type::Custom("custom".into())
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Custom("custom".into()))
|
||||
.output_type(Type::Custom("custom".into()))
|
||||
.category(Category::Custom("custom".into()))
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
Reference in New Issue
Block a user