mirror of
https://github.com/nushell/nushell.git
synced 2025-08-12 21:57:50 +02:00
Add more input/output type annotations (#7532)
This commit is contained in:
committed by
GitHub
parent
d27263af97
commit
4e1f94026c
@ -1,7 +1,7 @@
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Value,
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -13,7 +13,9 @@ impl Command for Complete {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("complete").category(Category::System)
|
||||
Signature::build("complete")
|
||||
.category(Category::System)
|
||||
.input_output_types(vec![(Type::Any, Type::Record(vec![]))])
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -3,7 +3,7 @@ use nu_engine::{current_dir, env_to_strings, CallExt};
|
||||
use nu_protocol::{
|
||||
ast::{Call, Expr},
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape,
|
||||
Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape, Type,
|
||||
};
|
||||
use std::os::unix::process::CommandExt;
|
||||
|
||||
@ -17,6 +17,7 @@ impl Command for Exec {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("exec")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Any)])
|
||||
.required("command", SyntaxShape::String, "the command to execute")
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -3,7 +3,7 @@ use nu_parser::{parse, parse_module_block, unescape_unquote_string};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack, StateWorkingSet};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -16,6 +16,9 @@ impl Command for NuCheck {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("nu-check")
|
||||
.input_output_types(vec![(Type::String, Type::Bool),
|
||||
(Type::ListStream, Type::Bool),
|
||||
(Type::List(Box::new(Type::Any)), Type::Bool)])
|
||||
// type is string to avoid automatically canonicalizing the path
|
||||
.optional("path", SyntaxShape::String, "File path to parse")
|
||||
.switch("as-module", "Parse content as module", Some('m'))
|
||||
|
@ -3,7 +3,8 @@ use std::time::Duration;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value,
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Type,
|
||||
Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -16,6 +17,7 @@ impl Command for Ps {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("ps")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Table(vec![]))])
|
||||
.switch(
|
||||
"long",
|
||||
"list all available columns for each entry",
|
||||
|
@ -3,7 +3,7 @@ use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError,
|
||||
Signature, Span, Spanned, SyntaxShape, Value,
|
||||
Signature, Span, Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
use winreg::{enums::*, RegKey};
|
||||
|
||||
@ -31,6 +31,7 @@ impl Command for RegistryQuery {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("registry query")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Any)])
|
||||
.switch("hkcr", "query the hkey_classes_root hive", None)
|
||||
.switch("hkcu", "query the hkey_current_user hive", None)
|
||||
.switch("hklm", "query the hkey_local_machine hive", None)
|
||||
|
@ -2,11 +2,13 @@ use fancy_regex::Regex;
|
||||
use itertools::Itertools;
|
||||
use nu_engine::env_to_strings;
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::ast::{Expr, Expression};
|
||||
use nu_protocol::did_you_mean;
|
||||
use nu_protocol::engine::{EngineState, Stack};
|
||||
use nu_protocol::{ast::Call, engine::Command, ShellError, Signature, SyntaxShape, Value};
|
||||
use nu_protocol::{Category, Example, ListStream, PipelineData, RawStream, Span, Spanned};
|
||||
use nu_protocol::{
|
||||
ast::{Call, Expr, Expression},
|
||||
did_you_mean,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, ListStream, PipelineData, RawStream, ShellError, Signature, Span, Spanned,
|
||||
SyntaxShape, Type, Value,
|
||||
};
|
||||
use nu_system::ForegroundProcess;
|
||||
use pathdiff::diff_paths;
|
||||
use std::collections::HashMap;
|
||||
@ -34,6 +36,7 @@ impl Command for External {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build(self.name())
|
||||
.input_output_types(vec![(Type::Any, Type::Any)])
|
||||
.switch("redirect-stdout", "redirect stdout to the pipeline", None)
|
||||
.switch("redirect-stderr", "redirect stderr to the pipeline", None)
|
||||
.switch("trim-end-newline", "trimming end newlines", None)
|
||||
|
@ -3,7 +3,7 @@ use chrono::Local;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Value,
|
||||
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||
};
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
use sysinfo::{ComponentExt, CpuExt, DiskExt, NetworkExt, System, SystemExt, UserExt};
|
||||
@ -17,7 +17,10 @@ impl Command for Sys {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("sys").filter().category(Category::System)
|
||||
Signature::build("sys")
|
||||
.filter()
|
||||
.category(Category::System)
|
||||
.input_output_types(vec![(Type::Nothing, Type::Record(vec![]))])
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -6,7 +6,7 @@ use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span,
|
||||
Spanned, SyntaxShape, Value,
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
use std::ffi::OsStr;
|
||||
@ -22,6 +22,8 @@ impl Command for Which {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("which")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Table(vec![]))])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("application", SyntaxShape::String, "application")
|
||||
.rest("rest", SyntaxShape::String, "additional applications")
|
||||
.switch("all", "list all executables", Some('a'))
|
||||
|
Reference in New Issue
Block a user