Class: S3Ranger::CLI::Sync

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSync

Returns a new instance of Sync.



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/s3ranger/cli.rb', line 236

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", "") {|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.



233
234
235
# File 'lib/s3ranger/cli.rb', line 233

def dry_run
  @dry_run
end

#excludeObject

Returns the value of attribute exclude.



231
232
233
# File 'lib/s3ranger/cli.rb', line 231

def exclude
  @exclude
end

#keepObject

Returns the value of attribute keep.



232
233
234
# File 'lib/s3ranger/cli.rb', line 232

def keep
  @keep
end

#s3Object

Returns the value of attribute s3.



230
231
232
# File 'lib/s3ranger/cli.rb', line 230

def s3
  @s3
end

#verboseObject

Returns the value of attribute verbose.



234
235
236
# File 'lib/s3ranger/cli.rb', line 234

def verbose
  @verbose
end

Instance Method Details

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



266
267
268
269
270
# File 'lib/s3ranger/cli.rb', line 266

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