mirror of
https://github.com/nushell/nushell
synced 2025-01-06 02:09:10 +00:00
ca0c6eaf58
with the `help` command to explore and list all commands available. Enter will also try to see if the location to be entered is an existing Nu command, if it is it will let you inspect the command under `help`. This provides baseline needed so we can iterate on it.
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use crate::commands::command::RunnablePerItemContext;
|
|
use crate::errors::ShellError;
|
|
use crate::parser::hir::SyntaxType;
|
|
use crate::parser::registry::{CommandRegistry, Signature};
|
|
use crate::prelude::*;
|
|
use std::path::PathBuf;
|
|
|
|
pub struct Cpy;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct CopyArgs {
|
|
pub src: Tagged<PathBuf>,
|
|
pub dst: Tagged<PathBuf>,
|
|
pub recursive: Tagged<bool>,
|
|
}
|
|
|
|
impl PerItemCommand for Cpy {
|
|
fn name(&self) -> &str {
|
|
"cp"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("cp")
|
|
.required("src", SyntaxType::Path)
|
|
.required("dst", SyntaxType::Path)
|
|
.named("file", SyntaxType::Any)
|
|
.switch("recursive")
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Copy files."
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
call_info: &CallInfo,
|
|
_registry: &CommandRegistry,
|
|
raw_args: &RawCommandArgs,
|
|
_input: Tagged<Value>,
|
|
) -> Result<OutputStream, ShellError> {
|
|
call_info.process(&raw_args.shell_manager, cp)?.run()
|
|
}
|
|
}
|
|
|
|
fn cp(args: CopyArgs, context: &RunnablePerItemContext) -> Result<OutputStream, ShellError> {
|
|
let shell_manager = context.shell_manager.clone();
|
|
shell_manager.cp(args, context)
|
|
}
|