diff options
Diffstat (limited to 'src/joshuto/command/new_directory.rs')
-rw-r--r-- | src/joshuto/command/new_directory.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/joshuto/command/new_directory.rs b/src/joshuto/command/new_directory.rs index 42f7899..fda2ef7 100644 --- a/src/joshuto/command/new_directory.rs +++ b/src/joshuto/command/new_directory.rs @@ -1,11 +1,8 @@ extern crate ncurses; -use std; use std::path; -use joshuto::command::ReloadDirList; -use joshuto::command::JoshutoCommand; -use joshuto::command::JoshutoRunnable; +use joshuto::command::{JoshutoCommand, JoshutoRunnable, ReloadDirList}; use joshuto::context::JoshutoContext; use joshuto::textfield::JoshutoTextField; use joshuto::ui; @@ -14,29 +11,36 @@ use joshuto::ui; pub struct NewDirectory; impl NewDirectory { - pub fn new() -> Self { NewDirectory } - pub const fn command() -> &'static str { "mkdir" } + pub fn new() -> Self { + NewDirectory + } + 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 - { + 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) - { + fn execute(&self, context: &mut JoshutoContext) { let (term_rows, term_cols) = ui::getmaxyx(); const PROMPT: &'static str = ":mkdir "; let user_input: Option<String>; { - let textfield = JoshutoTextField::new(1, term_cols, (term_rows as usize - 1, 0), PROMPT.to_string()); + let textfield = JoshutoTextField::new( + 1, + term_cols, + (term_rows as usize - 1, 0), + PROMPT.to_string(), + ); user_input = textfield.readline_with_initial("", ""); } @@ -46,10 +50,10 @@ impl JoshutoRunnable for NewDirectory { match std::fs::create_dir_all(&path) { Ok(_) => { ReloadDirList::reload(context); - }, + } Err(e) => { ui::wprint_err(&context.views.bot_win, e.to_string().as_str()); - }, + } } } |