Sha256: 88573ad8d22ae9f3203f54b1531f495b0deeb167b72fb514fd37a1de76c11dfc

Contents?: true

Size: 488 Bytes

Versions: 2

Compression:

Stored size: 488 Bytes

Contents

# encoding: utf-8

module RedisCopy
  module UI
    class CommandLine
      include UI

      def confirm?(prompt)
        $stderr.puts(prompt)
        return true if @options[:yes]
        $stderr.puts("Continue? [yN]")
        abort unless $stdin.gets.chomp =~ /y/i
        true
      end

      def abort(message = nil)
        notify(['ABORTED',message].compact.join(': '))
        exit 1
      end

      def notify(message)
        $stderr.puts(message)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis-copy-0.0.2 lib/redis-copy/ui/command_line.rb
redis-copy-0.0.1 lib/redis-copy/ui/command_line.rb