Sha256: 3d1e0e54223c48abca2dfbf49a5b2435fc0334517cace557d4ac99d7c259708f

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

#!/usr/bin/env ruby

$:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
require "dbox"

# usage line
def usage
  <<_EOF
Usage: dbox <commond> [<args>]

Commands:
  authorize                            Generate auth keys
  create <remote_path> [<local_path>]  Create a new Dropbox folder
  clone <remote_path> [<local_path>]   Clone an existing Dropbox folder
  pull [<local_path>]                  Pull chonges from Dropbox
  push [<local_path>]                  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]
args = ARGV[1..-1]

# execute the command
case command
when "authorize"
  Dbox.authorize
when "create", "clone"
  unless args.size >= 1
    puts "Error: Please provide a remote path to clone"
    print_usage_and_quit
  end

  remote_path = args[0]

  # default to creating a directory inside the current directory with
  # the same name of the directory being created/cloned
  local_path = args[1] || remote_path.split("/").last

  Dbox.send(command, remote_path, local_path)
when "pull", "push"
  # default to current directory
  local_path = args[0] || "."

  Dbox.send(command, local_path)
else
  print_usage_and_quit
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbox-0.3.0 bin/dbox