in storage/src/main/kotlin/Storage.kt [140:163]
fun delete(vararg params: String) { // 1 mandatory and 1 optional args expected: <bucket> [<blob>]
val bucketName = params[0]
val bucket = storage.get(bucketName)
?: error("Bucket $bucketName does not exist! To see your existing buckets, use command 'info'. \n $usage")
if (params.size == 1) { // 1 arg provided => Delete Bucket <bucket>
for (blob in bucket.list().iterateAll()) {
blob.delete()
}
bucket.delete()
println("Bucket $bucketName was successfully deleted.")
return
}
// 2 args provided (<bucket> and <blob>) => Delete Blob <blob> of Bucket <bucket>
val blobName = params[1]
val blob = bucket.get(blobName)
?: error("Blob $blobName does not exist! To see blobs in bucket $bucketName, use command 'info $bucketName'. \n $usage")
blob.delete()
println("Blob $blobName was successfully deleted from bucket $bucketName.")
}