class S3Ranger::CLI::DeleteBucket

Attributes

force[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/s3ranger/cli.rb, line 123
def initialize
  super 'deletebucket', false, false

  @short_desc = "Remove a bucket from your account"

  @force = false

  self.options = CmdParse::OptionParserWrapper.new do |opt|
    opt.on("-f", "--force", "Clean the bucket then deletes it") {|f|
      @force = f
    }
  end
end

Public Instance Methods

run(s3, bucket, key, file, args) click to toggle source
# File lib/s3ranger/cli.rb, line 137
def run s3, bucket, key, file, args
  raise WrongUsage.new(nil, "You need to inform a bucket") if not bucket

  # Getting the bucket
  bucket_obj = s3.buckets[bucket]

  # Do not kill buckets with content unless explicitly asked
  if not @force and bucket_obj.objects.count > 0
    raise FailureFeedback.new("Cowardly refusing to remove non-empty bucket `#{bucket}'. Try with -f.")
  end

  bucket_obj.delete!
end