forked from extern/nushell
Declare input and output types of commands (#6796)
* Add failing test that list of ints and floats is List<Number> * Start defining subtype relation * Make it possible to declare input and output types for commands - Enforce them in tests * Declare input and output types of commands * Add formatted signatures to `help commands` table * Revert SyntaxShape::Table -> Type::Table change * Revert unnecessary derive(Hash) on SyntaxShape Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
This commit is contained in:
@ -97,6 +97,9 @@ pub enum SyntaxShape {
|
||||
|
||||
/// A custom shape with custom completion logic
|
||||
Custom(Box<SyntaxShape>, DeclId),
|
||||
|
||||
/// Nothing
|
||||
Nothing,
|
||||
}
|
||||
|
||||
impl SyntaxShape {
|
||||
@ -127,14 +130,15 @@ impl SyntaxShape {
|
||||
SyntaxShape::Number => Type::Number,
|
||||
SyntaxShape::Operator => Type::Any,
|
||||
SyntaxShape::Range => Type::Any,
|
||||
SyntaxShape::Record => Type::Record(vec![]), // FIXME: Add actual record type
|
||||
SyntaxShape::Record => Type::Record(vec![]), // FIXME: What role should fields play in the Record type?
|
||||
SyntaxShape::RowCondition => Type::Bool,
|
||||
SyntaxShape::Boolean => Type::Bool,
|
||||
SyntaxShape::Signature => Type::Signature,
|
||||
SyntaxShape::String => Type::String,
|
||||
SyntaxShape::Table => Type::List(Box::new(Type::Any)), // FIXME: Tables should have better types
|
||||
SyntaxShape::Table => Type::List(Box::new(Type::Any)), // FIXME: What role should columns play in the Table type?
|
||||
SyntaxShape::VarWithOptType => Type::Any,
|
||||
SyntaxShape::Variable => Type::Any,
|
||||
SyntaxShape::Nothing => Type::Any,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,6 +178,7 @@ impl Display for SyntaxShape {
|
||||
SyntaxShape::Boolean => write!(f, "bool"),
|
||||
SyntaxShape::Error => write!(f, "error"),
|
||||
SyntaxShape::Custom(x, _) => write!(f, "custom<{}>", x),
|
||||
SyntaxShape::Nothing => write!(f, "nothing"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user