nushell/src/commands/mkdir.rs

41 lines
961 B
Rust
Raw Normal View History

use crate::commands::command::RunnablePerItemContext;
2019-08-07 04:45:38 +02:00
use crate::errors::ShellError;
2019-08-09 06:51:21 +02:00
use crate::parser::registry::{CommandRegistry, Signature};
2019-08-07 04:45:38 +02:00
use crate::prelude::*;
use std::path::PathBuf;
2019-08-07 04:45:38 +02:00
pub struct Mkdir;
#[derive(Deserialize)]
2019-08-21 19:03:59 +02:00
pub struct MkdirArgs {
pub rest: Vec<Tagged<PathBuf>>,
}
2019-08-15 07:02:02 +02:00
impl PerItemCommand for Mkdir {
2019-08-09 06:51:21 +02:00
fn run(
&self,
2019-08-15 07:02:02 +02:00
call_info: &CallInfo,
_registry: &CommandRegistry,
2019-08-15 07:02:02 +02:00
shell_manager: &ShellManager,
_input: Tagged<Value>,
2019-08-15 07:02:02 +02:00
) -> Result<VecDeque<ReturnValue>, ShellError> {
call_info.process(shell_manager, mkdir)?.run()
2019-08-07 04:45:38 +02:00
}
fn name(&self) -> &str {
"mkdir"
}
2019-08-09 06:51:21 +02:00
fn signature(&self) -> Signature {
Signature::build("mkdir").rest()
2019-08-07 04:45:38 +02:00
}
}
fn mkdir(
2019-08-21 19:03:59 +02:00
args: MkdirArgs,
context: &RunnablePerItemContext,
2019-08-15 07:02:02 +02:00
) -> Result<VecDeque<ReturnValue>, ShellError> {
2019-08-21 19:03:59 +02:00
let shell_manager = context.shell_manager.clone();
shell_manager.mkdir(args, context)
2019-08-07 04:45:38 +02:00
}