lib/cliprompt.rb in cliprompt-0.0.4 vs lib/cliprompt.rb in cliprompt-0.0.5
- old
+ new
@@ -14,31 +14,19 @@
def ask(question, *options)
if options[0].class == Optionset
opts = options[0]
else
- opts = Optionset.new *options
+ opts = Optionset.new(*options)
end
- if opts.aslist
- output.puts "#{question}"
- opts.choices.each_with_index do |choice, i|
- if opts.default == choice
- output.printf "> %-3s %s\n", i, choice
- else
- output.printf " %-3s %s\n", i, choice
- end
- end
- output.print "#{MSG_CHOSE_A_NUMBER} "
- else
- output.print "#{question} #{opts.display} "
- end
+ output.print "#{question} #{opts.display}"
answer = input.gets.chomp
output.flush
opts.validate(question, answer)
end
def guess(env, question, *options)
- opts = Optionset.new *options
+ opts = Optionset.new(*options)
if ENV[env]
opts.validate(question, ENV[env])
else
ask question, opts
end