mirror of
https://github.com/nushell/nushell.git
synced 2025-01-22 14:18:55 +01:00
some filesystem command signatures (#7464)
# Description Signature for the following commands: - `cd` - `cp` - `glob` - `ls` - `mkdir` - `mv` - `open` - `rm` - `save` - `touch` Related to https://github.com/nushell/nushell/issues/7320 Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
dae1b9a996
commit
5f48452e3b
@ -48,6 +48,7 @@ impl Command for Cd {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("cd")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.optional("path", SyntaxShape::Directory, "the path to change to")
|
||||
.input_output_types(vec![
|
||||
(Type::Nothing, Type::Nothing),
|
||||
|
@ -8,7 +8,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span,
|
||||
Spanned, SyntaxShape, Value,
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
use super::util::try_interaction;
|
||||
@ -40,6 +40,7 @@ impl Command for Cp {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("cp")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("source", SyntaxShape::GlobPattern, "the place to copy from")
|
||||
.required("destination", SyntaxShape::Filepath, "the place to copy to")
|
||||
.switch(
|
||||
|
@ -4,7 +4,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Spanned,
|
||||
SyntaxShape, Value,
|
||||
SyntaxShape, Type, Value,
|
||||
};
|
||||
use wax::{Glob as WaxGlob, WalkBehavior};
|
||||
|
||||
@ -18,6 +18,7 @@ impl Command for Glob {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("glob")
|
||||
.input_output_types(vec![(Type::Nothing, Type::List(Box::new(Type::String)))])
|
||||
.required("glob", SyntaxShape::String, "the glob expression")
|
||||
.named(
|
||||
"depth",
|
||||
|
@ -9,7 +9,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, DataSource, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData,
|
||||
PipelineMetadata, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
|
||||
PipelineMetadata, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
use pathdiff::diff_paths;
|
||||
|
||||
@ -37,6 +37,7 @@ impl Command for Ls {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("ls")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Table(vec![]))])
|
||||
// Using a string instead of a glob pattern shape so it won't auto-expand
|
||||
.optional("pattern", SyntaxShape::String, "the glob pattern to use")
|
||||
.switch("all", "Show hidden files", Some('a'))
|
||||
|
@ -6,7 +6,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature,
|
||||
SyntaxShape, Value,
|
||||
SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -19,6 +19,7 @@ impl Command for Mkdir {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("mkdir")
|
||||
.input_output_types(vec![(Type::Nothing, Type::List(Box::new(Type::String)))])
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::Directory,
|
||||
|
@ -7,7 +7,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span,
|
||||
Spanned, SyntaxShape, Value,
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
const GLOB_PARAMS: nu_glob::MatchOptions = nu_glob::MatchOptions {
|
||||
@ -35,6 +35,7 @@ impl Command for Mv {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("mv")
|
||||
.input_output_types(vec![(Type::Nothing, Type::List(Box::new(Type::String)))])
|
||||
.required(
|
||||
"source",
|
||||
SyntaxShape::GlobPattern,
|
||||
|
@ -3,7 +3,8 @@ use nu_engine::{eval_block, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Type,
|
||||
Value,
|
||||
};
|
||||
use std::io::BufReader;
|
||||
|
||||
@ -35,6 +36,7 @@ impl Command for Open {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("open")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Any), (Type::String, Type::Any)])
|
||||
.optional("filename", SyntaxShape::Filepath, "the filename to use")
|
||||
.switch("raw", "open file as raw binary", Some('r'))
|
||||
.category(Category::FileSystem)
|
||||
|
@ -44,7 +44,13 @@ impl Command for Rm {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
let sig = Signature::build("rm");
|
||||
let sig = Signature::build("rm")
|
||||
.input_output_types(vec![(Type::Nothing, Type::List(Box::new(Type::String)))])
|
||||
.required(
|
||||
"filename",
|
||||
SyntaxShape::Filepath,
|
||||
"the path of the file you want to remove",
|
||||
);
|
||||
#[cfg(all(
|
||||
feature = "trash-support",
|
||||
not(target_os = "android"),
|
||||
@ -73,7 +79,7 @@ impl Command for Rm {
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::GlobPattern,
|
||||
"the file path(s) to remove",
|
||||
"additional file path(s) to remove",
|
||||
)
|
||||
.category(Category::FileSystem)
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Type,
|
||||
Value,
|
||||
};
|
||||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
@ -35,6 +36,7 @@ impl Command for Save {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("save")
|
||||
.input_output_types(vec![(Type::Any, Type::Nothing)])
|
||||
.required("filename", SyntaxShape::Filepath, "the filename to use")
|
||||
.named(
|
||||
"stderr",
|
||||
|
@ -7,7 +7,9 @@ use filetime::FileTime;
|
||||
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,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Touch;
|
||||
@ -23,6 +25,7 @@ impl Command for Touch {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("touch")
|
||||
.input_output_types(vec![ (Type::Nothing, Type::Nothing) ])
|
||||
.required(
|
||||
"filename",
|
||||
SyntaxShape::Filepath,
|
||||
|
Loading…
Reference in New Issue
Block a user