Error with enum_select
This works:
choices = %w(emacs nano vim)
answer = @prompt.enum_select("Select an editor", choices, default: 3)
puts answer
This produces an error:
choices = %w(emacs nano vim)
answer = @prompt.enum_select("Select an editor", choices)
puts answer
Unhandled exception: default index 0 out of range (1 - 3) (Exception)
from lib/term-prompt/src/prompt/enum_list.cr:178:9 in 'validate_defaults'
from lib/term-prompt/src/prompt/enum_list.cr:186:9 in 'setup_defaults'
from lib/term-prompt/src/prompt/enum_list.cr:100:9 in 'call'
from lib/term-prompt/src/term-prompt.cr:240:7 in 'enum_select'
from lib/term-prompt/src/term-prompt.cr:245:7 in 'enum_select'
.
.
.
Seems like I have to specify a default value which I am doing for now. Using Crystal 0.35.1. Thanks again for this shard.
Is this fixed now? Sorry I didn't answer, but I didn't see this issue. It should be an easy fix to automatically default to the first option in the list though.
I'm using the default: parameter in the method call to work with this.
On Tue, 2021-10-26 at 12:33 -0700, Chris Watson wrote:
Is this fixed now? Sorry I didn't answer, but I didn't see this issue. It should be an easy fix to automatically default to the first option in the list though.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
-- There is no box.
- Random thoughts on Life
I'll go ahead and keep this open until I actually fix the main issue then. Thanks for your response :)