Class: S3Ranger::CLI::Sync
- Defined in:
- lib/s3ranger/cli.rb
Instance Attribute Summary collapse
-
#acl ⇒ Object
Returns the value of attribute acl.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#keep ⇒ Object
Returns the value of attribute keep.
-
#s3 ⇒ Object
Returns the value of attribute s3.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize ⇒ Sync
constructor
A new instance of Sync.
- #run(s3, bucket, key, file, args) ⇒ Object
- #usage ⇒ Object
Methods inherited from BaseCmd
Constructor Details
#initialize ⇒ Sync
Returns a new instance of Sync.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# 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. = 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 |
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
325 326 327 |
# File 'lib/s3ranger/cli.rb', line 325 def acl @acl end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
323 324 325 |
# File 'lib/s3ranger/cli.rb', line 323 def dry_run @dry_run end |
#exclude ⇒ Object
Returns the value of attribute exclude.
321 322 323 |
# File 'lib/s3ranger/cli.rb', line 321 def exclude @exclude end |
#keep ⇒ Object
Returns the value of attribute keep.
322 323 324 |
# File 'lib/s3ranger/cli.rb', line 322 def keep @keep end |
#s3 ⇒ Object
Returns the value of attribute s3.
320 321 322 |
# File 'lib/s3ranger/cli.rb', line 320 def s3 @s3 end |
#verbose ⇒ Object
Returns the value of attribute verbose.
324 325 326 |
# File 'lib/s3ranger/cli.rb', line 324 def verbose @verbose end |
Instance Method Details
#description ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# 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) ⇒ Object
386 387 388 389 390 |
# 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 ⇒ Object
359 360 361 |
# File 'lib/s3ranger/cli.rb', line 359 def usage "Usage: #{File.basename commandparser.program_name} #{name} source destination" end |