Sha256: 677bbbdbd11499f1e7776d6f8ea28da8d659172373577b793bbb968228d0face

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'mite-backup'
require 'optparse'

@options = {
  "wait_for" => MiteBackup::DEFAULT_WAIT_FOR
}

parser = OptionParser.new do |opts|
  opts.banner = "Usage: mite-backup COMMAND [options]"

  opts.separator ""
  opts.separator "Options:"

  opts.on("-a", "--account ACCOUNT-SUBDOMAIN", "your mite account subdomain (without .mite.yo.lk)") do |account|
    @options["account"] = account
  end

  opts.on("-e", "--email EMAIL", "mite.user email") do |email|
    @options["email"] = email
  end

  opts.on("-p", "--password PASSWORD", "mite.user password") do |password|
    @options["password"] = password
  end

  opts.on(
    "-w", "--wait-for SECONDS", Integer,
    "Number of seconds to wait for backup to be ready. Defaults to 240 seconds."
  ) do |seconds|
    @options["wait_for"] = seconds
  end

  opts.on("-c", "--clear", "Removes all config values from config file.") do
    @options["clear_config"] = true
  end

  opts.on("-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.separator ""
  opts.separator "Commands:"
  opts.separator "  get     Download backupfile and ouput xml to STDOUT (Default command)"
  opts.separator "  setup   Write given options to config file ~/.mite-backup.yml, so you don't need to repeat them on every get command."
  opts.separator ""
end

parser.parse!

case ARGV[0] || "get"
when 'get'
  MiteBackup.new(@options).run
when 'setup'
  MiteBackup.new(@options).setup
else
  $stderr.puts "Unknown command #{ARGV[0].inspect}"
  puts ""
  puts parser.help
  exit(1)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mite-backup-0.3.0 bin/mite-backup