Sha256: bd75b544953f5c40add9799607d45927adaee4690be09db35ff0f3532c4d3c03

Contents?: true

Size: 1.85 KB

Versions: 8

Compression:

Stored size: 1.85 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
  move <new_remote_path> [<local_path>] Move the remote Dropbox folder to a new location

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)
when "move"
  remote_path = args[0]

  # default to current directory
  local_path = args[1] || "."

  Dbox.send(command, remote_path, local_path)
else
  print_usage_and_quit
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dbox-0.5.2 bin/dbox
dbox-0.5.1 bin/dbox
dbox-0.5.0 bin/dbox
dbox-0.4.4 bin/dbox
dbox-0.4.3 bin/dbox
dbox-0.4.2 bin/dbox
dbox-0.4.1 bin/dbox
dbox-0.4.0 bin/dbox