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