2019-08-21 12:07:37 +00:00
|
|
|
use crate::commands::command::RunnablePerItemContext;
|
2019-08-07 02:45:38 +00:00
|
|
|
use crate::errors::ShellError;
|
2019-08-09 04:51:21 +00:00
|
|
|
use crate::parser::registry::{CommandRegistry, Signature};
|
2019-08-07 02:45:38 +00:00
|
|
|
use crate::prelude::*;
|
2019-08-21 12:07:37 +00:00
|
|
|
use std::path::PathBuf;
|
2019-08-07 02:45:38 +00:00
|
|
|
|
|
|
|
pub struct Mkdir;
|
|
|
|
|
2019-08-21 12:07:37 +00:00
|
|
|
#[derive(Deserialize)]
|
2019-08-21 17:03:59 +00:00
|
|
|
pub struct MkdirArgs {
|
|
|
|
pub rest: Vec<Tagged<PathBuf>>,
|
2019-08-21 12:07:37 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 05:02:02 +00:00
|
|
|
impl PerItemCommand for Mkdir {
|
2019-08-29 22:52:32 +00:00
|
|
|
fn name(&self) -> &str {
|
|
|
|
"mkdir"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
2019-09-11 07:53:05 +00:00
|
|
|
Signature::build("mkdir").rest(SyntaxType::Path)
|
2019-08-29 22:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"Make directories, creates intermediary directories as required."
|
|
|
|
}
|
|
|
|
|
2019-08-09 04:51:21 +00:00
|
|
|
fn run(
|
|
|
|
&self,
|
2019-08-15 05:02:02 +00:00
|
|
|
call_info: &CallInfo,
|
2019-08-21 12:07:37 +00:00
|
|
|
_registry: &CommandRegistry,
|
2019-08-29 03:53:45 +00:00
|
|
|
raw_args: &RawCommandArgs,
|
2019-08-21 12:07:37 +00:00
|
|
|
_input: Tagged<Value>,
|
2019-08-24 19:36:19 +00:00
|
|
|
) -> Result<OutputStream, ShellError> {
|
2019-08-29 03:53:45 +00:00
|
|
|
call_info.process(&raw_args.shell_manager, mkdir)?.run()
|
2019-08-07 02:45:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-24 19:36:19 +00:00
|
|
|
fn mkdir(args: MkdirArgs, context: &RunnablePerItemContext) -> Result<OutputStream, ShellError> {
|
2019-08-21 17:03:59 +00:00
|
|
|
let shell_manager = context.shell_manager.clone();
|
|
|
|
shell_manager.mkdir(args, context)
|
2019-08-07 02:45:38 +00:00
|
|
|
}
|