lib/eco/api/common/session/helpers/prompt_user.rb in eco-helpers-2.4.9 vs lib/eco/api/common/session/helpers/prompt_user.rb in eco-helpers-2.5.1
- old
+ new
@@ -1,32 +1,32 @@
-require 'timeout'
module Eco
module API
module Common
module Session
module Helpers
module PromptUser
-
+ # Prompts user for input with option for default on timeout.
def prompt_user(question, default:, explanation: "", timeout: nil)
- response = if config.run_mode_remote?
- default
- else
- puts explanation
- print "#{question} "
- if timeout
- begin
- Timeout::timeout(timeout) { STDIN.gets.chop }
- rescue Timeout::Error
- default
- end
- else
- STDIN.gets.chop
- end
- end
+ require 'timeout'
+ response = \
+ if config.run_mode_remote?
+ default
+ else
+ puts explanation
+ print "#{question} "
+ if timeout
+ begin
+ Timeout::timeout(timeout) { STDIN.gets.chop }
+ rescue Timeout::Error
+ default
+ end
+ else
+ STDIN.gets.chop
+ end
+ end
return response unless block_given?
yield(response)
end
-
end
end
end
end
end