alanvardy / tod

An unofficial Todoist command line client written in Rust
MIT License
90 stars 9 forks source link

Allow going back on menu #729

Open stacksjb opened 1 month ago

stacksjb commented 1 month ago

If I incorrectly select "Pick project" and really wanted to delete, there is no way to go back.

This should probably be a default universal thing, such as pressing left arrow when no text is present, pressing escape (currently exits the program instead of going back a menu), another keyboard shortcut, or simply a "Go back to previous" option added to all menus.

stacksjb commented 1 month ago

It appears this does not work on "Select Project", but it does work as expected on each task under "tod list process" so it may be inconsistent.

I can go through and test each function(s) if needed.

stacksjb commented 1 month ago

I think using "escape" may be appropriate (I can always ctrl-c to break).

"Tod list process" also simply cancels if I hit escape and exits.

alanvardy commented 1 month ago

I can go through and test each function(s) if needed.

This would be a big help if you can :pray:

stacksjb commented 3 weeks ago

I will look through this, thx.

stacksjb commented 2 weeks ago

I'm not super familiar with inquire and need to test this - but can you re-map the escape key? so instead of "operation cancelled" it just goes back to the previous option?

That would accomplish the required result much more easily instead of having to add a "back" option to every single menu option.

Otherwise we would need to add something like menu_options.push("q. Back".to_string()); to ever single menu option, and then keep track of the next and previous menus.

Below is a validation of all of the current menus in Tod (and the structure).

Note that most sub-menus need it as well, and many single command (but prompts) have no way of exit/cancel/back - I opened an issue on Inquire to check into this further and see if it might be possible (since that would certainly be easier!)

For the most part, every single "project selection" and "filter selection" option menu needs it - not sure if you're calling the same function universally, but if so that might make keeping track of previous/next menu a bit of work (would need to probably pass in/keep track of the previous menu?)

Also there are a few menus (Such as list process) that do have a "quit" option, which exits the program - this could be reassigned to "back", I don't think we need both "Back" and "Quit"

alanvardy commented 2 weeks ago

I don't think that I can remap, but I can definitely match on the error call the function again so that the user can select from the beginning if they hit escape.

"Operation was canceled by the user"

Based on my testing, Ctrl+c and Esc are treated the same way, so I would need to provide a quit option to allow the user to escape the menu.

stacksjb commented 2 weeks ago

If you can go back to the first menu, that might be a good middle ground.

alanvardy commented 2 weeks ago