mirror of
https://github.com/nushell/nushell.git
synced 2025-07-13 21:06:06 +02:00
This improves incremental build time when working on what was previously the root package. For example, previously all plugins would be rebuilt with a change to `src/commands/classified/external.rs`, but now only `nu-cli` will have to be rebuilt (and anything that depends on it).
55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
use crate::commands::command::RunnablePerItemContext;
|
|
use crate::context::CommandRegistry;
|
|
use crate::prelude::*;
|
|
use nu_errors::ShellError;
|
|
use nu_protocol::{CallInfo, Signature, SyntaxShape, Value};
|
|
use nu_source::Tagged;
|
|
use std::path::PathBuf;
|
|
|
|
pub struct Remove;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct RemoveArgs {
|
|
pub target: Tagged<PathBuf>,
|
|
pub recursive: Tagged<bool>,
|
|
pub trash: Tagged<bool>,
|
|
}
|
|
|
|
impl PerItemCommand for Remove {
|
|
fn name(&self) -> &str {
|
|
"rm"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("rm")
|
|
.required("path", SyntaxShape::Pattern, "the file path to remove")
|
|
.switch(
|
|
"trash",
|
|
"use the platform's recycle bin instead of permanently deleting",
|
|
Some('t'),
|
|
)
|
|
.switch("recursive", "delete subdirectories recursively", Some('r'))
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Remove a file"
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
call_info: &CallInfo,
|
|
_registry: &CommandRegistry,
|
|
raw_args: &RawCommandArgs,
|
|
_input: Value,
|
|
) -> Result<OutputStream, ShellError> {
|
|
call_info
|
|
.process(&raw_args.shell_manager, raw_args.ctrl_c.clone(), rm)?
|
|
.run()
|
|
}
|
|
}
|
|
|
|
fn rm(args: RemoveArgs, context: &RunnablePerItemContext) -> Result<OutputStream, ShellError> {
|
|
let shell_manager = context.shell_manager.clone();
|
|
shell_manager.rm(args, context)
|
|
}
|