blob: afeb12d3bca8468fa69e5a9009f0e4e1a39981f8 [file] [log] [blame]
Austin Schuh99f7c6a2024-06-25 22:07:44 -07001#include "absl/log/check.h"
2#include "absl/log/log.h"
Yash Maheshwarie0b25c52024-05-22 20:23:36 -07003
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_swerve/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_swerve::ConstantsList> constants =
16 aos::JsonFileToFlatbuffer<y2024_swerve::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}