feat: navigation slightly improved
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/target
|
||||
.blueprints
|
||||
|
||||
@@ -74,7 +74,3 @@ pub fn get_base_template_paths() -> Vec<String> {
|
||||
|
||||
base_paths
|
||||
}
|
||||
|
||||
// ╭───────────────────────╮
|
||||
// │- Write to filesystem -│
|
||||
// ╰───────────────────────╯
|
||||
|
||||
28
src/main.rs
28
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user