Class: RedisCopy::UI::CommandLine

Inherits:
Object
  • Object
show all
Includes:
RedisCopy::UI
Defined in:
lib/redis-copy/ui/command_line.rb

Instance Method Summary collapse

Methods included from RedisCopy::UI

#debug, #initialize, load

Instance Method Details

#abort(message = nil) ⇒ Object



16
17
18
19
# File 'lib/redis-copy/ui/command_line.rb', line 16

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

#confirm?(prompt) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'lib/redis-copy/ui/command_line.rb', line 8

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

#notify(message) ⇒ Object



21
22
23
# File 'lib/redis-copy/ui/command_line.rb', line 21

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