use crate::commands::command::RunnablePerItemContext; use crate::errors::ShellError; use crate::parser::hir::SyntaxShape; use crate::parser::registry::{CommandRegistry, Signature}; use crate::prelude::*; use nu_source::Tagged; use std::path::PathBuf; pub struct Cpy; #[derive(Deserialize)] pub struct CopyArgs { pub src: Tagged, pub dst: Tagged, pub recursive: Tagged, } impl PerItemCommand for Cpy { fn name(&self) -> &str { "cp" } fn signature(&self) -> Signature { Signature::build("cp") .required("src", SyntaxShape::Pattern, "the place to copy from") .required("dst", SyntaxShape::Path, "the place to copy to") .switch("recursive", "copy recursively through subdirectories") } fn usage(&self) -> &str { "Copy files." } fn run( &self, call_info: &CallInfo, _registry: &CommandRegistry, raw_args: &RawCommandArgs, _input: Value, ) -> Result { call_info.process(&raw_args.shell_manager, cp)?.run() } } fn cp(args: CopyArgs, context: &RunnablePerItemContext) -> Result { let shell_manager = context.shell_manager.clone(); shell_manager.cp(args, context) }