blob: 2a72c38916acf109aceb6fd7a50245ff3da307c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
use std::path;
use crate::commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList};
use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
use crate::ui::TuiBackend;
#[derive(Clone, Debug)]
pub struct NewDirectory {
paths: Vec<path::PathBuf>,
}
impl NewDirectory {
pub fn new(paths: Vec<path::PathBuf>) -> Self {
NewDirectory { paths }
}
pub const fn command() -> &'static str {
"mkdir"
}
}
impl JoshutoCommand for NewDirectory {}
impl std::fmt::Display for NewDirectory {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(Self::command())
}
}
impl JoshutoRunnable for NewDirectory {
fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> {
for path in &self.paths {
std::fs::create_dir_all(path)?;
}
ReloadDirList::reload(context.curr_tab_index, context)?;
Ok(())
}
}
|