diff --git a/.gitignore b/.gitignore index ea8c4bf..6fec0a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.blueprints diff --git a/src/files/mod.rs b/src/files/mod.rs index c16ed6b..76c3c90 100644 --- a/src/files/mod.rs +++ b/src/files/mod.rs @@ -74,7 +74,3 @@ pub fn get_base_template_paths() -> Vec { base_paths } - -// ╭───────────────────────╮ -// │- Write to filesystem -│ -// ╰───────────────────────╯ diff --git a/src/main.rs b/src/main.rs index 1b96e46..00395fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,13 +31,15 @@ fn main() { if let Ok(target_name) = target_name_result { let mut target_path_heap = "./".to_string(); - const CONFIRM_OPTION: &str = "-- Current --"; - const CANCEL_OPTION: &str = "-- Cancel --"; + const CONFIRM_OPTION: &str = " ✔ Current"; + const PREV_DIR_OPTION: &str = " ↩ Previous"; + const CANCEL_OPTION: &str = " 🗙Cancel"; - loop { + 'input_loop: loop { let mut sub_directory_list = get_sub_dirs_paths(&target_path_heap); - sub_directory_list.insert(0, CONFIRM_OPTION.to_string()); - sub_directory_list.push(CANCEL_OPTION.to_string()); + sub_directory_list.insert(0, PREV_DIR_OPTION.to_string()); + sub_directory_list.insert(1, CONFIRM_OPTION.to_string()); + sub_directory_list.insert(2, CANCEL_OPTION.to_string()); let target_path_result = Select::new( &format!( @@ -50,23 +52,27 @@ fn main() { if let Ok(target_path) = target_path_result { // TODO: also check if dir has no subdirs if target_path == CANCEL_OPTION { - break; - } - - if target_path == CONFIRM_OPTION { + break 'input_loop; + } else if target_path == PREV_DIR_OPTION { + target_path_heap = target_path_heap + .rsplit_once("/") + .unwrap_or((&target_path_heap, "")) + .0 + .to_string(); + } else if target_path == CONFIRM_OPTION { create_template( template_path.clone(), target_name.clone(), target_path_heap.clone(), ) .unwrap(); - break; + break 'input_loop; } else { target_path_heap = target_path; } } else { // TODO: manage Error - break; + break 'input_loop; } } }