#!/usr/bin/env ruby $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")) require "dbox" # usage line def usage <<_EOF Usage: dbox [] Commands: authorize Generate auth keys create [] Create a new Dropbox folder clone [] Clone an existing Dropbox folder pull [] Pull chonges from Dropbox push [] Push changes to Dropbox Environment varables needed for everything: export DROPBOX_APP_KEY=cmlrrjd3j0gbend export DROPBOX_APP_SECRET=uvuulp75xf9jffl Environment varables needed for everything other than authorize: export DROPBOX_AUTH_KEY=v4d7l1rez1czksn export DROPBOX_AUTH_SECRET=pqej9rmnj0i1gcxr4 See http://github.com/kenpratt/dbox for examples and more information _EOF end def print_usage_and_quit; puts usage; exit 1; end # ensure that push/pull arg was given print_usage_and_quit unless ARGV.size >= 1 command = ARGV[0] rest = ARGV[1..-1] # execute the command case command when "authorize" Dbox.authorize when "create", "clone" unless rest.size >= 1 puts "Error: Please provide a remote path to clone" print_usage_and_quit end Dbox.send(command, *rest) when "pull", "push" Dbox.send(command, *rest) else print_usage_and_quit end