Class: S3Sync::CLI::Sync

Inherits:
BaseCmd
  • Object
show all
Defined in:
lib/s3sync/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCmd

#execute, #has_options?, #has_prefix?

Constructor Details

#initializeSync

Returns a new instance of Sync.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/s3sync/cli.rb', line 361

def initialize
  super 'sync', takes_commands: false #, false

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

  self.options 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

Instance Attribute Details

#aclObject

Returns the value of attribute acl.



359
360
361
# File 'lib/s3sync/cli.rb', line 359

def acl
  @acl
end

#dry_runObject

Returns the value of attribute dry_run.



357
358
359
# File 'lib/s3sync/cli.rb', line 357

def dry_run
  @dry_run
end

#excludeObject

Returns the value of attribute exclude.



355
356
357
# File 'lib/s3sync/cli.rb', line 355

def exclude
  @exclude
end

#keepObject

Returns the value of attribute keep.



356
357
358
# File 'lib/s3sync/cli.rb', line 356

def keep
  @keep
end

#s3Object

Returns the value of attribute s3.



354
355
356
# File 'lib/s3sync/cli.rb', line 354

def s3
  @s3
end

#verboseObject

Returns the value of attribute verbose.



358
359
360
# File 'lib/s3sync/cli.rb', line 358

def verbose
  @verbose
end

Instance Method Details

#descriptionObject



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/s3sync/cli.rb', line 397

def description
  @description ="\nWhere `source' and `description' might be either local or remote\naddresses. A local address is simply a path in your local file\nsystem. e.g:\n\n    /tmp/notes.txt\n\nA remote address is a combination of the `bucket` name and\nan optional `prefix`:\n\n    disc.company.com:reports/2013/08/30.html\n\nSo, a full example would be something like this\n\n    $ \#{File.basename commandparser.program_name} sync Work/reports disc.company.com:reports/2013/08\n\nThe above line will update the remote folder `reports/2013/08` with the\ncontents of the local folder `Work/reports`.\n".strip
end

#run(s3, bucket, key, file, args) ⇒ Object



420
421
422
423
424
# File 'lib/s3sync/cli.rb', line 420

def run s3, bucket, key, file, args
  @s3 = s3
  cmd = SyncCommand.new self, *args
  cmd.run
end

#usageObject



393
394
395
# File 'lib/s3sync/cli.rb', line 393

def usage
  "Usage: #{File.basename commandparser.program_name} #{name} source destination"
end