summaryrefslogtreecommitdiffstats
path: root/src/commands/new_directory.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-05-26 18:28:58 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-05-26 18:28:58 -0400
commit829d8b9ff0806ffc2da692f12b9e8a6f5c228aa4 (patch)
treefb018bafc4c8568d447825e5da3c17263d74466e /src/commands/new_directory.rs
parent397506b398aa1cc6d03a154ae1792815131f8125 (diff)
update commands to use new textfield
Diffstat (limited to 'src/commands/new_directory.rs')
-rw-r--r--src/commands/new_directory.rs31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/commands/new_directory.rs b/src/commands/new_directory.rs
index 022ebe9..b388aa7 100644
--- a/src/commands/new_directory.rs
+++ b/src/commands/new_directory.rs
@@ -7,27 +7,16 @@ use crate::window::JoshutoView;
#[derive(Clone, Debug)]
pub struct NewDirectory {
- path: path::PathBuf,
+ paths: Vec<path::PathBuf>,
}
impl NewDirectory {
- pub fn new(path: path::PathBuf) -> Self {
- NewDirectory { path }
+ pub fn new(paths: Vec<path::PathBuf>) -> Self {
+ NewDirectory { paths }
}
pub const fn command() -> &'static str {
"mkdir"
}
-
- fn new_directory(
- context: &mut JoshutoContext,
- view: &JoshutoView,
- path: &path::Path,
- ) -> Result<(), std::io::Error> {
- std::fs::create_dir_all(path)?;
- ReloadDirList::reload(context, view)?;
- ncurses::doupdate();
- Ok(())
- }
}
impl JoshutoCommand for NewDirectory {}
@@ -44,9 +33,17 @@ impl JoshutoRunnable for NewDirectory {
context: &mut JoshutoContext,
view: &JoshutoView,
) -> Result<(), JoshutoError> {
- match Self::new_directory(context, view, self.path.as_path()) {
- Ok(_) => Ok(()),
- Err(e) => Err(JoshutoError::IO(e)),
+ for path in &self.paths {
+ match std::fs::create_dir_all(path) {
+ Ok(_) => {}
+ Err(e) => return Err(JoshutoError::IO(e)),
+ }
+ }
+ match ReloadDirList::reload(context, view) {
+ Ok(_) => {}
+ Err(e) => return Err(JoshutoError::IO(e)),
}
+ ncurses::doupdate();
+ Ok(())
}
}