On Nov 15, 2008, at 7:18 AM, szimek wrote: > On 14 Lis, 14:52, James Gray <ja... / grayproductions.net> wrote: >> On Nov 14, 2008, at 4:23 AM, szimek wrote: >> >>> Hi, >> >> Hello. >> >>> I've got an array of user logins and need to provide a way to select >>> one or more of them with auto-completion. Currently I've got code >>> straight from readline example: >> >>> users = ask("Select users: ", user_logins) do |q| >>> q.readline = true >>> end >> >>> The problem is that it says "You must choose one of...." if I select >>> more than one login. How to allow to select multiple choices? >> >> Is it okay to ask the user to enter one login per line with a blank >> line to end? If so, this code should work: >> >> #!/usr/bin/env ruby -wKU >> >> require "rubygems" >> require "highline/import" >> >> LOGINS = %w[bob joe dave alice hal] >> >> selected = ask("Select Users:", LOGINS + [""]) do |q| >> q.readline = true >> q.gather = "" >> end >> p selected >> >> __END__ >> >> Hope that helps. >> >> James Edward Gray II > > Thanks, I'll probably use this solution for now, but is it possible at > all with highline to make it in a single line? Not with autocompletion, no. HighLine doesn't allow you to manually set the autocompletion Proc used by Readline. Perhaps we should, but then if you do that you probably aren't gaining anything from HighLine and you should probably just use Readline manually. > Another question: I'd like user to be able to select a ticket number > from a list with auto-complete. But if user presses tab, I'd like to > display not only possible ticket numbers, but their descriptions as > well - one entry (i.e. "1234 - something doesn't work") per line, if > it's possible. Sure, just set an Array of Strings with the number and description as you show above for the values. They will auto complete fine, and you can strip the description after you have their answer. James Edward Gray II