class S3Ranger::CLI::Sync

Attributes

acl[RW]
dry_run[RW]
exclude[RW]
keep[RW]
s3[RW]
verbose[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/s3ranger/cli.rb, line 327
def initialize
  super 'sync', false, false

  @short_desc = "Synchronize an S3 and a local folder"
  @s3 = nil
  @exclude = nil
  @keep = false
  @dry_run = false
  @verbose = false

  self.options = CmdParse::OptionParserWrapper.new do |opt|
    opt.on("-x EXPR", "--exclude=EXPR", "Skip copying files that matches this pattern. (Ruby REs)") {|v|
      @exclude = v
    }

    opt.on("-k", "--keep", "Keep files even if they don't exist in source") {
      @keep = true
    }

    parse_acl(opt)

    opt.on("-d", "--dry-run", "Do not download or exclude anything, just show what was planned. Implies `verbose`.") {
      @dry_run = true
      @verbose = true
    }

    opt.on("-v", "--verbose", "Show file names") {
      @verbose = true
    }
  end
end

Public Instance Methods

description() click to toggle source
# File lib/s3ranger/cli.rb, line 363
      def description
        @description =<<END.strip

Where `source' and `description' might be either local or remote
addresses. A local address is simply a path in your local file
system. e.g:

    /tmp/notes.txt

A remote address is a combination of the `bucket` name and
an optional `prefix`:

    disc.company.com:reports/2013/08/30.html

So, a full example would be something like this

    $ #{File.basename commandparser.program_name} sync Work/reports disc.company.com:reports/2013/08

The above line will update the remote folder `reports/2013/08` with the
contents of the local folder `Work/reports`.
END
      end
run(s3, bucket, key, file, args) click to toggle source
# File lib/s3ranger/cli.rb, line 386
def run s3, bucket, key, file, args
  @s3 = s3
  cmd = SyncCommand.new self, *args
  cmd.run
end
usage() click to toggle source
# File lib/s3ranger/cli.rb, line 359
def usage
  "Usage: #{File.basename commandparser.program_name} #{name} source destination"
end