Class: S3Sync::CLI::DeleteBucket
- Defined in:
- lib/s3sync/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
#execute, #has_options?, #has_prefix?, #usage
Constructor Details
#initialize ⇒ DeleteBucket
Returns a new instance of DeleteBucket.
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/s3sync/cli.rb', line 149 def initialize super 'deletebucket', takes_commands: false #, false @short_desc = "Remove a bucket from your account" @force = false self. 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.
147 148 149 |
# File 'lib/s3sync/cli.rb', line 147 def force @force end |
Instance Method Details
#run(s3, bucket, key, file, args) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/s3sync/cli.rb', line 163 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.bucket(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 |