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 {
35 desc.add_options()
36 (
"files,f", boost::program_options::value<std::vector<std::string> >(&files)->multitoken()->
required(),
"oks files")
37 ("include,i", boost::program_options::value<std::vector<std::string> >(&include)->multitoken(), "preload oks files (to fix missing includes)")
38 ("show-all-attributes,x", "show hidden attributes with values equal to defaults")
39 ("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 {
48 std::cout << desc << std::endl;
49 return EXIT_SUCCESS;
50 }
51
52 if (vm.count("show-all-attributes"))
53 show_hidden_attributes = true;
54 }
55 catch (std::exception& ex)
56 {
57 std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
58 return EXIT_FAILURE;
59 }
60
61 for (const auto &x : files)
62 try
63 {
64 std::cout << "processing file " << x << std::endl;
65 OksKernel kernel(
false,
false,
false,
false);
66
67 for(const auto& i : include)
68 kernel.load_file(i);
69
70 auto f = kernel.load_file(x);
71
72 if (
f->get_oks_format() ==
"schema")
73 kernel.save_schema(f);
74 else
75 kernel.save_data(f, true, nullptr, show_hidden_attributes);
76 }
77 catch (oks::exception &ex)
78 {
79 oks::log_timestamp(oks::Error) << "Caught oks exception:\n" << ex << std::endl;
80 return EXIT_FAILURE;
81 }
82
83 return EXIT_SUCCESS;
84}
Provides interface to the OKS kernel.