#!/usr/bin/env ruby $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'mite-backup' require 'optparse' @options = {} parser = OptionParser.new do |opts| opts.banner = "Usage: mite-backup COMMAND [options]" opts.separator "" opts.separator "Options:" opts.on("-a", "--account [ACCOUNT]", "your mite account-name (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("-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 the on ever 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