Maxwell Henderson | 3d6d5bf | 2024-02-24 12:49:51 -0800 | [diff] [blame^] | 1 | #include "glog/logging.h" |
| 2 | |
| 3 | #include "aos/flatbuffers.h" |
| 4 | #include "aos/init.h" |
| 5 | #include "aos/json_to_flatbuffer.h" |
| 6 | #include "aos/util/file.h" |
| 7 | #include "y2024/constants/constants_list_generated.h" |
| 8 | |
| 9 | int main(int argc, char **argv) { |
| 10 | ::aos::InitGoogle(&argc, &argv); |
| 11 | |
| 12 | CHECK(argc == 3) << ": Expected input and output json files to be passed in."; |
| 13 | |
| 14 | aos::FlatbufferDetachedBuffer<y2024::ConstantsList> constants = |
| 15 | aos::JsonFileToFlatbuffer<y2024::ConstantsList>(argv[1]); |
| 16 | |
| 17 | // Make sure the file is valid json before we output a formatted version. |
| 18 | CHECK(constants.message().constants() != nullptr) |
| 19 | << ": Failed to parse " << std::string(argv[2]); |
| 20 | |
| 21 | aos::util::WriteStringToFileOrDie( |
| 22 | std::string(argv[2]), |
| 23 | aos::FlatbufferToJson(constants, {.multi_line = true})); |
| 24 | |
| 25 | return 0; |
| 26 | } |