mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:37:45 +02:00
Add more input/output type annotations (#7532)
This commit is contained in:
committed by
GitHub
parent
d27263af97
commit
4e1f94026c
6
crates/nu-command/src/env/config/config_.rs
vendored
6
crates/nu-command/src/env/config/config_.rs
vendored
@ -2,7 +2,7 @@ use nu_engine::get_full_help;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, IntoPipelineData, PipelineData, Signature, Value,
|
||||
Category, IntoPipelineData, PipelineData, Signature, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -14,7 +14,9 @@ impl Command for ConfigMeta {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Env)
|
||||
Signature::build(self.name())
|
||||
.category(Category::Env)
|
||||
.input_output_types(vec![(Type::Nothing, Type::String)])
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::env_to_strings;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, Type,
|
||||
};
|
||||
|
||||
use crate::ExternalCommand;
|
||||
@ -18,7 +18,10 @@ impl Command for ConfigEnv {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Env)
|
||||
Signature::build(self.name())
|
||||
.category(Category::Env)
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
// TODO: Signature narrower than what run actually supports theoretically
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::env_to_strings;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned,
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, Type,
|
||||
};
|
||||
|
||||
use crate::ExternalCommand;
|
||||
@ -18,7 +18,10 @@ impl Command for ConfigNu {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Env)
|
||||
Signature::build(self.name())
|
||||
.category(Category::Env)
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
// TODO: Signature narrower than what run actually supports theoretically
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
6
crates/nu-command/src/env/env_command.rs
vendored
6
crates/nu-command/src/env/env_command.rs
vendored
@ -2,7 +2,7 @@ use nu_engine::env_to_string;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Value,
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -18,7 +18,9 @@ impl Command for Env {
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("env").category(Category::Env)
|
||||
Signature::build("env")
|
||||
.category(Category::Env)
|
||||
.input_output_types(vec![(Type::Nothing, Type::Table(vec![]))])
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
4
crates/nu-command/src/env/let_env.rs
vendored
4
crates/nu-command/src/env/let_env.rs
vendored
@ -2,7 +2,7 @@ use nu_engine::{eval_expression_with_input, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -19,6 +19,8 @@ impl Command for LetEnv {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("let-env")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("var_name", SyntaxShape::String, "variable name")
|
||||
.required(
|
||||
"initial_value",
|
||||
|
6
crates/nu-command/src/env/load_env.rs
vendored
6
crates/nu-command/src/env/load_env.rs
vendored
@ -1,7 +1,9 @@
|
||||
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 LoadEnv;
|
||||
@ -17,6 +19,8 @@ impl Command for LoadEnv {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("load-env")
|
||||
.input_output_types(vec![(Type::Record(vec![]), Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.optional(
|
||||
"update",
|
||||
SyntaxShape::Record,
|
||||
|
3
crates/nu-command/src/env/source_env.rs
vendored
3
crates/nu-command/src/env/source_env.rs
vendored
@ -4,7 +4,7 @@ use nu_engine::{eval_block, find_in_dirs_env, redirect_env, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
/// Source a file for environment variables.
|
||||
@ -18,6 +18,7 @@ impl Command for SourceEnv {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("source-env")
|
||||
.input_output_types(vec![(Type::Any, Type::Any)])
|
||||
.required(
|
||||
"filename",
|
||||
SyntaxShape::String, // type is string to avoid automatically canonicalizing the path
|
||||
|
Reference in New Issue
Block a user