Skip to content

Commit 6412895

Browse files
Clean up method signature on ask* methods
1 parent 6407746 commit 6412895

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/thor/shell/basic.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ def padding=(value)
4747
#
4848
def ask(statement, *args)
4949
options = args.last.is_a?(Hash) ? args.pop : {}
50+
color = args.first
5051

51-
options[:limited_to] ? ask_filtered(statement, options, *args) : ask_simply(statement, options, *args)
52+
if options[:limited_to]
53+
ask_filtered(statement, color, options)
54+
else
55+
ask_simply(statement, color, options)
56+
end
5257
end
5358

5459
# Say (print) something to the user. If the sentence ends with a whitespace
@@ -372,7 +377,7 @@ def as_unicode
372377
end
373378
end
374379

375-
def ask_simply(statement, options = {}, color=nil)
380+
def ask_simply(statement, color, options)
376381
default = options[:default]
377382
message = [statement, ("(#{default.inspect})" if default), nil].uniq.join(" ")
378383
say(message, color)
@@ -389,11 +394,11 @@ def ask_simply(statement, options = {}, color=nil)
389394
end
390395
end
391396

392-
def ask_filtered(statement, options = {}, *args)
397+
def ask_filtered(statement, color, options)
393398
answer_set = options[:limited_to]
394399
correct_answer = nil
395400
until correct_answer
396-
answer = ask_simply("#{statement} #{answer_set.inspect}", options, *args)
401+
answer = ask_simply("#{statement} #{answer_set.inspect}", color, options)
397402
correct_answer = answer_set.include?(answer) ? answer : nil
398403
answers = answer_set.map(&:inspect).join(", ")
399404
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer

0 commit comments

Comments
 (0)