Add more input/output type annotations (#7532)

This commit is contained in:
Stefan Holderbach
2022-12-21 20:20:46 +01:00
committed by GitHub
parent d27263af97
commit 4e1f94026c
78 changed files with 324 additions and 186 deletions

View File

@ -2,7 +2,7 @@ use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Example, HistoryFileFormat, IntoInterruptiblePipelineData, PipelineData, ShellError,
Signature, Span, Value,
Signature, Span, Type, Value,
};
use reedline::{
FileBackedHistory, History as ReedlineHistory, HistoryItem, SearchDirection, SearchQuery,
@ -23,6 +23,11 @@ impl Command for History {
fn signature(&self) -> nu_protocol::Signature {
Signature::build("history")
.input_output_types(vec![
(Type::Nothing, Type::Table(vec![])),
(Type::Nothing, Type::Nothing),
])
.allow_variants_without_examples(true)
.switch("clear", "Clears out the history entries", Some('c'))
.switch(
"long",

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, IntoPipelineData, PipelineData, Signature, Value};
use nu_protocol::{Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value};
#[derive(Clone)]
pub struct HistorySession;
@ -15,7 +15,9 @@ impl Command for HistorySession {
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("history session").category(Category::Misc)
Signature::build("history session")
.category(Category::Misc)
.input_output_types(vec![(Type::Nothing, Type::Int)])
}
fn examples(&self) -> Vec<Example> {

View File

@ -4,7 +4,7 @@ use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape,
Value,
Type, Value,
};
#[derive(Clone)]
@ -17,6 +17,8 @@ impl Command for Tutor {
fn signature(&self) -> Signature {
Signature::build("tutor")
.input_output_types(vec![(Type::Nothing, Type::String)])
.allow_variants_without_examples(true)
.optional(
"search",
SyntaxShape::String,