blob: 0af18a98fac46a5afdb2f597d227695c030c94a9 [file] [log] [blame]
Austin Schuh99f7c6a2024-06-25 22:07:44 -07001#include "absl/log/check.h"
2#include "absl/log/log.h"
Maxwell Henderson3d6d5bf2024-02-24 12:49:51 -08003
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/constants/constants_list_generated.h"
9
10int 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::ConstantsList> constants =
16 aos::JsonFileToFlatbuffer<y2024::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}