Sha256: 82c417d1b324586ed5656d99603994201a900438556ccb198f09f234080a528e

Contents?: true

Size: 586 Bytes

Versions: 3

Compression:

Stored size: 586 Bytes

Contents

# encoding: utf-8

module RedisCopy
  module UI
    class CommandLine
      implements UI do |options|
        options[:ui].to_s.underscore.dasherize == 'command-line'
      end

      def confirm?(prompt)
        $stderr.puts(prompt)
        return true unless @options[:prompt]
        $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

3 entries across 3 versions & 1 rubygems

Version Path
redis-copy-1.0.0 lib/redis-copy/ui/command_line.rb
redis-copy-1.0.0.rc.1 lib/redis-copy/ui/command_line.rb
redis-copy-1.0.0.rc.0 lib/redis-copy/ui/command_line.rb