2019-08-20 11:20:48 +00:00
|
|
|
use crate::commands::command::RunnablePerItemContext;
|
2019-07-17 19:51:18 +00:00
|
|
|
use crate::errors::ShellError;
|
|
|
|
use crate::parser::hir::SyntaxType;
|
2019-08-20 11:20:48 +00:00
|
|
|
use crate::parser::registry::{CommandRegistry, Signature};
|
2019-07-20 02:27:10 +00:00
|
|
|
use crate::prelude::*;
|
2019-08-02 19:15:07 +00:00
|
|
|
use std::path::PathBuf;
|
2019-07-17 19:51:18 +00:00
|
|
|
|
|
|
|
pub struct Remove;
|
|
|
|
|
2019-08-20 11:20:48 +00:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
pub struct RemoveArgs {
|
2019-08-21 17:03:59 +00:00
|
|
|
pub target: Tagged<PathBuf>,
|
|
|
|
pub recursive: Tagged<bool>,
|
2019-08-20 11:20:48 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 05:02:02 +00:00
|
|
|
impl PerItemCommand for Remove {
|
2019-07-17 19:51:18 +00:00
|
|
|
fn name(&self) -> &str {
|
|
|
|
"rm"
|
|
|
|
}
|
|
|
|
|
2019-08-02 19:15:07 +00:00
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("rm")
|
|
|
|
.required("path", SyntaxType::Path)
|
|
|
|
.switch("recursive")
|
|
|
|
}
|
2019-07-17 19:51:18 +00:00
|
|
|
|
2019-08-02 19:15:07 +00:00
|
|
|
fn run(
|
|
|
|
&self,
|
2019-08-15 05:02:02 +00:00
|
|
|
call_info: &CallInfo,
|
|
|
|
_registry: &CommandRegistry,
|
|
|
|
shell_manager: &ShellManager,
|
|
|
|
_input: Tagged<Value>,
|
2019-08-24 19:36:19 +00:00
|
|
|
) -> Result<OutputStream, ShellError> {
|
2019-08-20 11:20:48 +00:00
|
|
|
call_info.process(shell_manager, rm)?.run()
|
2019-07-17 19:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-24 19:36:19 +00:00
|
|
|
fn rm(args: RemoveArgs, context: &RunnablePerItemContext) -> Result<OutputStream, ShellError> {
|
2019-08-21 17:03:59 +00:00
|
|
|
let shell_manager = context.shell_manager.clone();
|
|
|
|
shell_manager.rm(args, context)
|
2019-07-17 19:51:18 +00:00
|
|
|
}
|