From: David Zafman Date: Thu, 4 Dec 2014 00:38:22 +0000 (-0800) Subject: ceph_objectstore_tool: For terminal output of list one object per line X-Git-Tag: v0.80.10~69^2~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=06579b9f269dc9864e920368c5bea9bcb9dd8be9;p=ceph.git ceph_objectstore_tool: For terminal output of list one object per line Instead of a parsable array make it easier to cut and paste listed objects Signed-off-by: David Zafman (cherry picked from commit 5a66db9418aeed31fec98999c5053dab357d9c1e) --- diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 6f438fe5cbd8..00a371c83a2b 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -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 >::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(); } };