in storage/src/main/kotlin/Storage.kt [74:101]
fun info(vararg params: String) { // 1 optional arg expected: [<bucket>]
if (params.isEmpty()) { // No arg provided => Storage Info => List all buckets in storage
if (storage.list().iterateAll().count() == 0) {
println("Looks like your storage is empty. You can create a bucket with the 'create' command. \n $usage")
return
}
println("Listing all buckets in your storage: \n")
for (bucket in storage.list().iterateAll()) {
println(bucket.name)
}
return
}
// 1 optional arg provided: <bucket> => Bucket Info => List all blobs in <bucket>
val bucketName = params[0]
val bucket = storage.get(bucketName)
?: error("Bucket $bucketName does not exist. You can create a new bucket with the command 'create <bucket>'. \n $usage")
if (bucket.list().iterateAll().count() == 0) {
println("Looks like your bucket is empty. You can upload blobs to your bucket with the 'upload' command. \n $usage")
return
}
println("Listing all blobs in bucket $bucketName: \n")
for (blob in bucket.list().iterateAll()) {
println("Name: ${blob.name} \t Content Type: ${blob.contentType} \t Size: ${blob.size}")
}
}