Class: TrashMan::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/trashman/cli.rb

Instance Method Summary collapse

Instance Method Details

#pruneObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/trashman/cli.rb', line 22

def prune
  if options.dry_run
    say "This is a dry-run. No files will be deleted."
  end

  manager = TrashMan::Manager.new(options.provider, options)
  count = manager.cleanup! do |file|
    say " -- deleting #{file.key}", :yellow
  end

  if options.dry_run
    say "This was a dry-run. No files were deleted."
  else
    say "#{count} file(s) deleted.", :green
  end
# This seems dirty.
# However, if the Fog::Storage provider throws any error,
# the user will be notified. Errors can be related to
# authentication, nonexistent bucket, etc.
rescue => e
  say e.message
end