Sha256: b796e9fa4127a59f19d201a661126d6dda4b5edd4dcf1be9af206394904fa637

Contents?: true

Size: 710 Bytes

Versions: 11

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

require 'thor'

module Dsu
  module Support
    module Ask
      def ask(prompt)
        options = {}
        Thor::LineEditor.readline(prompt, options)
      end

      def yes?(prompt, options: {})
        auto_prompt = auto_prompt(prompt, options)

        return auto_prompt unless auto_prompt.nil?

        Thor::Base.shell.new.yes?(prompt)
      end

      private

      def auto_prompt(prompt, options)
        prompt = Utils.strip_escapes(prompt)
        @auto_prompt ||= begin
          value = options.dig('prompts', prompt) || options.dig('prompts', 'any')
          value = (value == 'true' unless value.nil?)
          value
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dsu-2.3.1 lib/dsu/support/ask.rb
dsu-2.3.0 lib/dsu/support/ask.rb
dsu-2.2.2 lib/dsu/support/ask.rb
dsu-2.2.1 lib/dsu/support/ask.rb
dsu-2.2.0 lib/dsu/support/ask.rb
dsu-2.2.0.rc.2 lib/dsu/support/ask.rb
dsu-2.2.0.rc.1 lib/dsu/support/ask.rb
dsu-2.1.4 lib/dsu/support/ask.rb
dsu-2.1.3 lib/dsu/support/ask.rb
dsu-2.1.2 lib/dsu/support/ask.rb
dsu-2.1.1 lib/dsu/support/ask.rb