Move input/output type from Command to Signature (#5880)

This commit is contained in:
JT
2022-06-26 09:23:56 +12:00
committed by GitHub
parent 575ddbd4ef
commit f2989bf704
117 changed files with 344 additions and 981 deletions

View File

@ -10,6 +10,7 @@ use crate::BlockId;
use crate::PipelineData;
use crate::ShellError;
use crate::SyntaxShape;
use crate::Type;
use crate::VarId;
use std::fmt::Write;
@ -106,6 +107,8 @@ pub struct Signature {
pub optional_positional: Vec<PositionalArg>,
pub rest_positional: Option<PositionalArg>,
pub named: Vec<Flag>,
pub input_type: Type,
pub output_type: Type,
pub is_filter: bool,
pub creates_scope: bool,
// Signature category used to classify commands stored in the list of declarations
@ -135,6 +138,8 @@ impl Signature {
required_positional: vec![],
optional_positional: vec![],
rest_positional: None,
input_type: Type::Any,
output_type: Type::Any,
named: vec![],
is_filter: false,
creates_scope: false,
@ -314,6 +319,18 @@ impl Signature {
self
}
/// Changes the input type of the command signature
pub fn input_type(mut self, input_type: Type) -> Signature {
self.input_type = input_type;
self
}
/// Changes the output type of the command signature
pub fn output_type(mut self, output_type: Type) -> Signature {
self.output_type = output_type;
self
}
/// Changes the signature category
pub fn category(mut self, category: Category) -> Signature {
self.category = category;