Sha256: 5346ae36372641308ca594e6c261eac8a0cac09bc818c8a29289025ce9df06eb
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
Contents
module Capistrano class Configuration class Question def initialize(key, default, options={}) @key = key @default = default @options = options end def call ask_question value_or_default end private attr_reader :key, :default, :options def ask_question $stdout.print question end def value_or_default if response.empty? default else response end end def response return @response if defined? @response @response = (gets || "").chomp end def gets if echo? $stdin.gets else $stdin.noecho(&:gets).tap { $stdout.print "\n" } end rescue Errno::EIO # when stdio gets closed return end def question I18n.t(:question, key: key, default_value: default, scope: :capistrano) end def echo? (options || {}).fetch(:echo, true) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems