26{
27 boost::program_options::options_description desc("This program opens and saves oks files to refresh their format");
28
29 std::vector<std::string>
include;
30 std::vector<std::string> files;
31 bool show_hidden_attributes = false;
32
33 try {
34 desc.add_options()("files,f",
35 boost::program_options::value<std::vector<std::string>>(&files)->multitoken()->
required(),
36 "oks files")("include,i",
37 boost::program_options::value<std::vector<std::string>>(&
include)->multitoken(),
38 "preload oks files (to fix missing includes)")(
39 "show-all-attributes,x", "show hidden attributes with values equal to defaults")("help,h", "Print help message");
40
41 boost::program_options::variables_map vm;
42 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
43
44 boost::program_options::notify(vm);
45
46 if (vm.count("help")) {
47 std::cout << desc << std::endl;
48 return EXIT_SUCCESS;
49 }
50
51 if (vm.count("show-all-attributes"))
52 show_hidden_attributes = true;
53 } catch (std::exception& ex) {
54 std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
55 return EXIT_FAILURE;
56 }
57
58 for (const auto& x : files)
59 try {
60 std::cout << "processing file " << x << std::endl;
61 OksKernel kernel(
false,
false,
false,
false);
62
64 kernel.load_file(i);
65
66 auto f = kernel.load_file(x);
67
68 if (
f->get_oks_format() ==
"schema")
69 kernel.save_schema(f);
70 else
71 kernel.save_data(f, true, nullptr, show_hidden_attributes);
72 } catch (oks::exception& ex) {
73 oks::log_timestamp(oks::Error) << "Caught oks exception:\n" << ex << std::endl;
74 return EXIT_FAILURE;
75 }
76
77 return EXIT_SUCCESS;
78}
Provides interface to the OKS kernel.