24int main(
int argc,
char **argv) {
25 enum Exitcode :
int {SUCCESS, BADCMD, NOFILE, LOADFAIL, BADRELATIONSHIP};
27 CLI::App app{
"Check consistency of OKS schema file\n"+
28 fmt::format(
"Return codes: {} Success, file is OK\n", Exitcode::SUCCESS)+
29 fmt::format(
" {} Bad command line\n", Exitcode::BADCMD)+
30 fmt::format(
" {} Failed to find file\n", Exitcode::NOFILE)+
31 fmt::format(
" {} Failed to load file -- invalid schema\n", Exitcode::LOADFAIL)+
32 fmt::format(
" {} File contains relationship to non loaded class\n", Exitcode::BADRELATIONSHIP)
36 app.add_option(
"-f,--file",
filename,
"Schema file")
39 CLI11_PARSE(app, argc, argv);
44 if (file ==
nullptr) {
46 return Exitcode::LOADFAIL;
51 return Exitcode::LOADFAIL;
55 return Exitcode::NOFILE;
57 catch (std::exception& exc) {
58 TLOG() << exc.what() <<
"\n";
59 return Exitcode::LOADFAIL;
62 for (
auto [name, oks_class] : kernel.
classes()) {
63 auto relationships = oks_class->direct_relationships();
64 if (relationships !=
nullptr) {
65 for (
auto rel: *relationships) {
66 auto rel_class = rel->get_class_type();
67 if (rel_class ==
nullptr) {
68 TLOG() <<
"Error class '" << name
69 <<
"' has relationship '" << rel->get_name()
70 <<
"' to a class '" << rel->get_type()
71 <<
"' that is not loaded\n";
72 return Exitcode::BADRELATIONSHIP;