Sha256: cb6e9b11a7634e0a2d2adb6a599265e30ebd8fea196c942290c677e7cdd71dee
Contents?: true
Size: 958 Bytes
Versions: 2
Compression:
Stored size: 958 Bytes
Contents
# frozen_string_literal: true module Roro module Configurators class QuestionAsker < Thor include Thor::Actions no_commands do def override_default(question) prompt = "Please supply a value:" answer = ask([question, prompt].join("\n")) answer.size > 1 ? answer : override_default(question) end def confirm_default(question, hash) options = { "y": "yes", "n": "no", 'a': 'accept all defaults'} humanized_options = options.map {|key, value| "(#{key}) #{value}" } getsome = "Would you like to accept the default value?\n" prompt = [question, getsome, humanized_options, "\n"].join("\n") case ask(prompt, path: hash[:path]) when 'y' hash[:value] when 'n' override_default(question) when 'a' '' end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roro-0.3.33 | lib/roro/configurators/question_asker.rb |
roro-0.3.30 | lib/roro/configurators/question_asker.rb |