Sha256: 7f67e23402e41824c58a0134546ba16ac11c4ad34384aeda2c29d7e1c13b300a

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

require 'concurrent/delay'
module Bolt
  class Plugin
    class Prompt
      def initialize(*_args); end

      def name
        'prompt'
      end

      def hooks
        [:resolve_reference]
      end

      def validate_resolve_reference(opts)
        raise Bolt::ValidationError, "Prompt requires a 'message'" unless opts['message']
      end

      def resolve_reference(opts)
        # rubocop:disable Style/GlobalVars
        $future ? STDERR.print("#{opts['message']}:") : STDOUT.print("#{opts['message']}:")
        value = STDIN.noecho(&:gets).chomp
        $future ? STDERR.puts : STDOUT.puts
        # rubocop:enable Style/GlobalVars

        value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bolt-1.37.0 lib/bolt/plugin/prompt.rb
bolt-1.36.0 lib/bolt/plugin/prompt.rb