Class: S3Ranger::CLI::Sync

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCmd

#has_options?, #has_prefix?

Constructor Details

#initializeSync

Returns a new instance of Sync.



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/s3ranger/cli.rb', line 321

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
    }

    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

#dry_runObject

Returns the value of attribute dry_run.



318
319
320
# File 'lib/s3ranger/cli.rb', line 318

def dry_run
  @dry_run
end

#excludeObject

Returns the value of attribute exclude.



316
317
318
# File 'lib/s3ranger/cli.rb', line 316

def exclude
  @exclude
end

#keepObject

Returns the value of attribute keep.



317
318
319
# File 'lib/s3ranger/cli.rb', line 317

def keep
  @keep
end

#s3Object

Returns the value of attribute s3.



315
316
317
# File 'lib/s3ranger/cli.rb', line 315

def s3
  @s3
end

#verboseObject

Returns the value of attribute verbose.



319
320
321
# File 'lib/s3ranger/cli.rb', line 319

def verbose
  @verbose
end

Instance Method Details

#descriptionObject



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/s3ranger/cli.rb', line 355

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



378
379
380
381
382
# File 'lib/s3ranger/cli.rb', line 378

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

#usageObject



351
352
353
# File 'lib/s3ranger/cli.rb', line 351

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