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,9 @@ use super::{get_current_shell, get_shells};
use nu_engine::{current_dir, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
/// Source a file for environment variables.
#[derive(Clone)]
@ -15,6 +17,7 @@ impl Command for Enter {
fn signature(&self) -> Signature {
Signature::build("enter")
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
.required(
"path",
SyntaxShape::Filepath,

View File

@ -2,7 +2,9 @@ use super::{get_current_shell, get_last_shell, get_shells};
use nu_engine::{current_dir, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct Exit;
@ -14,6 +16,7 @@ impl Command for Exit {
fn signature(&self) -> Signature {
Signature::build("exit")
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
.optional(
"exit_code",
SyntaxShape::Int,

View File

@ -2,7 +2,9 @@ use super::{list_shells, switch_shell, SwitchTo};
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type,
};
/// Source a file for environment variables.
#[derive(Clone)]
@ -15,6 +17,10 @@ impl Command for GotoShell {
fn signature(&self) -> Signature {
Signature::build("g")
.input_output_types(vec![
(Type::Nothing, Type::Nothing),
(Type::Nothing, Type::Table(vec![])),
])
.optional(
"shell_number",
SyntaxShape::String,

View File

@ -1,7 +1,7 @@
use super::{switch_shell, SwitchTo};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type};
/// Source a file for environment variables.
#[derive(Clone)]
@ -13,7 +13,9 @@ impl Command for NextShell {
}
fn signature(&self) -> Signature {
Signature::build("n").category(Category::Shells)
Signature::build("n")
.category(Category::Shells)
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
}
fn usage(&self) -> &str {

View File

@ -1,7 +1,7 @@
use super::{switch_shell, SwitchTo};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type};
/// Source a file for environment variables.
#[derive(Clone)]
@ -13,7 +13,9 @@ impl Command for PrevShell {
}
fn signature(&self) -> Signature {
Signature::build("p").category(Category::Shells)
Signature::build("p")
.category(Category::Shells)
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
}
fn usage(&self) -> &str {

View File

@ -1,7 +1,7 @@
use super::list_shells;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Type};
/// Source a file for environment variables.
#[derive(Clone)]
@ -13,7 +13,9 @@ impl Command for Shells {
}
fn signature(&self) -> Signature {
Signature::build("shells").category(Category::Shells)
Signature::build("shells")
.category(Category::Shells)
.input_output_types(vec![(Type::Nothing, Type::Table(vec![]))])
}
fn usage(&self) -> &str {