Updated Branches:
  refs/heads/master 6c5e5346d -> a5574c05c

Emit header only when listing multiple containers

Also mimic the output of ls more closely, specifically not indenting
blob names.  This commit allows script to more easily consume output.
Fixes JCLOUDS-125.


Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds-karaf/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-karaf/commit/a5574c05
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-karaf/tree/a5574c05
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-karaf/diff/a5574c05

Branch: refs/heads/master
Commit: a5574c05cff38204e43e1cb6cd9fdd3b9c794f7b
Parents: 6c5e534
Author: Andrew Gaul <[email protected]>
Authored: Fri Jun 14 16:22:40 2013 -0700
Committer: Andrew Gaul <[email protected]>
Committed: Fri Jun 14 16:28:28 2013 -0700

----------------------------------------------------------------------
 .../karaf/commands/blobstore/BlobListCommand.java | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-jclouds-karaf/blob/a5574c05/commands/src/main/java/org/jclouds/karaf/commands/blobstore/BlobListCommand.java
----------------------------------------------------------------------
diff --git 
a/commands/src/main/java/org/jclouds/karaf/commands/blobstore/BlobListCommand.java
 
b/commands/src/main/java/org/jclouds/karaf/commands/blobstore/BlobListCommand.java
index 566f995..30bc5d4 100644
--- 
a/commands/src/main/java/org/jclouds/karaf/commands/blobstore/BlobListCommand.java
+++ 
b/commands/src/main/java/org/jclouds/karaf/commands/blobstore/BlobListCommand.java
@@ -18,7 +18,6 @@
 package org.jclouds.karaf.commands.blobstore;
 
 import java.io.PrintStream;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -42,7 +41,7 @@ import org.jclouds.blobstore.options.ListContainerOptions;
 public class BlobListCommand extends BlobStoreCommandWithOptions {
 
    @Argument(index = 0, name = "containerNames", description = "The name of 
the container", required = false, multiValued = true)
-   final Collection<String> containerNames = Lists.newArrayList();
+   final List<String> containerNames = Lists.newArrayList();
 
    @Option(name = "-a", aliases = "--all", description = "List all 
containers", required = false)
    boolean listAllContainers = false;
@@ -64,9 +63,14 @@ public class BlobListCommand extends 
BlobStoreCommandWithOptions {
          throw new CommandException("Must specify container names or --all");
       }
 
-      for (String containerName : containerNames) {
-         out.println(containerName + ":");
-         out.println();
+      for (int i = 0; i < containerNames.size(); ++i) {
+         String containerName = containerNames.get(i);
+         if (containerNames.size() > 1) {
+             if (i != 0) {
+                 out.println();
+             }
+             out.println(containerName + ":");
+         }
 
          ListContainerOptions options = 
ListContainerOptions.Builder.recursive();
 
@@ -82,7 +86,7 @@ public class BlobListCommand extends 
BlobStoreCommandWithOptions {
 
             Collections.sort(blobNames);
             for (String blobName : blobNames) {
-               out.println("    " + blobName);
+               out.println(blobName);
             }
 
             String marker = blobStoreMetadatas.getNextMarker();
@@ -92,8 +96,6 @@ public class BlobListCommand extends 
BlobStoreCommandWithOptions {
 
             options = options.afterMarker(marker);
          }
-
-         out.println();
       }
       return null;
    }

Reply via email to