]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_objectstore_tool: For terminal output of list one object per line
authorDavid Zafman <dzafman@redhat.com>
Thu, 4 Dec 2014 00:38:22 +0000 (16:38 -0800)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Mar 2015 19:20:58 +0000 (11:20 -0800)
Instead of a parsable array make it easier to cut and paste listed objects

Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 5a66db9418aeed31fec98999c5053dab357d9c1e)

src/tools/ceph_objectstore_tool.cc

index 6f438fe5cbd825b4ce507c5bf1b8cd24be66f24f..00a371c83a2bc5666618f8d892f2b04ac943f060 100644 (file)
@@ -457,10 +457,16 @@ struct pgid_object_list {
   }
 
   void dump(Formatter *f) const {
-    f->open_array_section("pgid_objects");
+    bool terminal = isatty(STDOUT_FILENO);
+    if (!terminal)
+      f->open_array_section("pgid_objects");
     for (list<pair<coll_t, ghobject_t> >::const_iterator i = _objects.begin();
         i != _objects.end();
         i++) {
+      if (i != _objects.begin() && terminal) {
+        f->flush(cout);
+        cout << std::endl;
+      }
       f->open_array_section("pgid_object");
       i->first.dump(f);
       f->open_object_section("ghobject");
@@ -468,7 +474,8 @@ struct pgid_object_list {
       f->close_section();
       f->close_section();
     }
-    f->close_section();
+    if (!terminal)
+      f->close_section();
   }
 };