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