Module: Backup::CLI::Helpers

Defined in:
lib/backup/cli.rb

Overview

This is to avoid Thor’s warnings when stubbing methods on the Thor class.

Class Method Summary collapse

Class Method Details

.exec!(cmd) ⇒ Object



361
362
363
364
# File 'lib/backup/cli.rb', line 361

def exec!(cmd)
  puts "Launching: #{ cmd }"
  exec(cmd)
end

.is_backup_error?(error) ⇒ Boolean

Returns:

  • (Boolean)


366
367
368
# File 'lib/backup/cli.rb', line 366

def is_backup_error?(error)
  error.class.ancestors.include? Backup::Error
end

.overwrite?(path) ⇒ Boolean

Returns:

  • (Boolean)


353
354
355
356
357
358
359
# File 'lib/backup/cli.rb', line 353

def overwrite?(path)
  return true unless File.exist?(path)

  $stderr.print "A file already exists at '#{ path }'.\n" +
                "Do you want to overwrite? [y/n] "
  /^[Yy]/ =~ $stdin.gets
end