Allow full expansion of AOS messages
The -pretty flag in aos_dump is intended to unwrap AOS messages to
one field per line, but doesn’t fully do so for all messages. Add
a flag to force unwrapping to one field per line.
Change-Id: I9cab18d1fc4a67c50d7ca06b35c69f63b39c5041
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/aos_dump.cc b/aos/aos_dump.cc
index 1662b47..a13ad9a 100644
--- a/aos/aos_dump.cc
+++ b/aos/aos_dump.cc
@@ -14,6 +14,9 @@
"If true, fetch the current message on the channel first");
DEFINE_bool(pretty, false,
"If true, pretty print the messages on multiple lines");
+DEFINE_bool(
+ pretty_max, false,
+ "If true, expand every field to its own line (expands more than -pretty)");
DEFINE_bool(print_timestamps, true, "If true, timestamps are printed.");
DEFINE_uint64(count, 0,
"If >0, aos_dump will exit after printing this many messages.");
@@ -44,7 +47,8 @@
aos::FlatbufferToJson(
builder, channel->schema(), static_cast<const uint8_t *>(context.data),
- {FLAGS_pretty, static_cast<size_t>(FLAGS_max_vector_size)});
+ {FLAGS_pretty, static_cast<size_t>(FLAGS_max_vector_size),
+ FLAGS_pretty_max});
if (FLAGS_print_timestamps) {
if (context.monotonic_remote_time != context.monotonic_event_time) {
diff --git a/aos/flatbuffer_introspection.cc b/aos/flatbuffer_introspection.cc
index b7f3727..b442af8 100644
--- a/aos/flatbuffer_introspection.cc
+++ b/aos/flatbuffer_introspection.cc
@@ -300,7 +300,9 @@
const int child_tree_depth = tree_depth + 1;
bool wrap = false;
- if (json_options.multi_line) {
+ if (json_options.max_multi_line) {
+ wrap = true;
+ } else if (json_options.multi_line) {
// Check whether this object has objects, vectors, or floats inside of it
for (const reflection::Field *field : *obj->fields()) {
if (ShouldCauseWrapping(field->type()->base_type())) {
diff --git a/aos/json_to_flatbuffer.h b/aos/json_to_flatbuffer.h
index 1f475be..7168e4c 100644
--- a/aos/json_to_flatbuffer.h
+++ b/aos/json_to_flatbuffer.h
@@ -38,10 +38,13 @@
}
struct JsonOptions {
- // controls if the Json is written ouut on multiple lines or one.
+ // controls if the Json is written out on multiple lines or one.
bool multi_line = false;
// the contents of vectors longer than max_vector_size will be skipped.
size_t max_vector_size = SIZE_MAX;
+ // more extensive version of multi_line that prints every single field on its
+ // own line.
+ bool max_multi_line = false;
};
// Converts a flatbuffer into a Json string.