]> git.apps.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)
committerLoic Dachary <ldachary@redhat.com>
Fri, 5 Dec 2014 12:01:36 +0000 (13:01 +0100)
Instead of a parsable array make it easier to cut and paste listed objects

Signed-off-by: David Zafman <dzafman@redhat.com>
src/tools/ceph_objectstore_tool.cc

index 433dadef8f83caeb647a158579216668862020d2..c99de6d413ed0fccfe46759dcc03203e4cd14c54 100644 (file)
@@ -459,10 +459,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");
@@ -470,7 +476,8 @@ struct pgid_object_list {
       f->close_section();
       f->close_section();
     }
-    f->close_section();
+    if (!terminal)
+      f->close_section();
   }
 };