Class: S3Ranger::CLI::DeleteBucket
- Defined in:
- lib/s3ranger/cli.rb
Instance Attribute Summary collapse
-
#force ⇒ Object
Returns the value of attribute force.
Instance Method Summary collapse
-
#initialize ⇒ DeleteBucket
constructor
A new instance of DeleteBucket.
- #run(s3, bucket, key, file, args) ⇒ Object
Methods inherited from BaseCmd
#has_options?, #has_prefix?, #usage
Constructor Details
#initialize ⇒ DeleteBucket
Returns a new instance of DeleteBucket.
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/s3ranger/cli.rb', line 118 def initialize super 'deletebucket', false, false @short_desc = "Remove a bucket from your account" @force = false self. = CmdParse::OptionParserWrapper.new do |opt| opt.on("-f", "--force", "Clean the bucket then deletes it") {|f| @force = f } end end |
Instance Attribute Details
#force ⇒ Object
Returns the value of attribute force.
116 117 118 |
# File 'lib/s3ranger/cli.rb', line 116 def force @force end |
Instance Method Details
#run(s3, bucket, key, file, args) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/s3ranger/cli.rb', line 132 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 |