aisk / pick

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

Passing a tuple with single value causes every letter is an option instead of the whole value #117

Closed amitie10g closed 4 months ago

amitie10g commented 4 months ago

Hi, I found this issue when passing a tuple with dynamic ammount of values.

options = os.getenv('OPTIONS').split(';')
pick(option, 'Select an option:', indicator='=>', default_index=0)

By passing a list (created by split()) with single value to pick(), it properly output the single option:

Select an option:

=> Single option

However, when passing a tuple with a single value to pick():

options = ('Single option')

every letter on the value become an option:

Select an option:

=> S
   i
   n
   g
   l
   e

   o
   p
   t
   i
   o
   n

I'm using Python 3.11 with pick 2.2.0 on Windows.

wong2 commented 4 months ago

Hi, ('Single option') is not a tuple, it results in a string value:

>>> options = ('Single option')
>>> options
'Single option'

This is a tuple with a single value: ('Single option',)

aisk commented 4 months ago

If there is no further questions, I'll close it. Feel free to reopen it if you have more context about this issue.