aisk / pick

create curses based interactive selection list in the terminal
MIT License
721 stars 60 forks source link

feat: added ability to quit early #126

Closed Henri-ColibrITD closed 1 month ago

Henri-ColibrITD commented 3 months ago

As mentioned in https://github.com/aisk/pick/pull/90, it would be useful for me to be able to quit before making the choice. This is my proposition on how to do it

aisk commented 3 months ago

Hi, please avoid formatting codes you don't touch. If you want to format the code, a new PR is welcome.

Henri-ColibrITD commented 3 months ago

Oh right, my bad, I'm too used to have my auto formatter always on, this should be reverted!

aisk commented 3 months ago

I have a concern that the current user doesn't have the codes to handle the result of (None, -1), and this could crash their process.

Can we simply add an optional parameter to the pick function, allowing the user to pass a list of keys, such as KEYS_QUIT, with the default value being None? In this way, the code will retain its original behavior if users don't pass this argument.

What's your opinion on this?

Henri-ColibrITD commented 3 months ago

What's your opinion on this?

I like the idea. I wanted to avoid affecting the signature as much as possible, but I think a default option serves this role perfectly

aisk commented 2 months ago

Except for the minor review comment, this change looks good to me. However, an update for the README.md in the Options section and a simple example in basic.py would be more appreciated. Could you please add these changes to this PR? @Henri-ColibrITD