File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 11#include < CLI/App.hpp>
22#include < CLI/Config.hpp>
33#include < CLI/Formatter.hpp>
4+ #include < fstream>
5+
6+ #include " nlohmann/json-schema.hpp"
7+
8+ using namespace nlohmann ;
9+ using namespace nlohmann ::json_schema;
410
511int main (int argc, char *argv[])
612{
13+ std::ifstream schema_input;
14+ std::ifstream object_input;
15+
716 CLI::App app{" Json schema validator" , " json-validator" };
817 // TODO: Move to a generated header file
918 app.set_version_flag (" --version" , " 2.2.0" );
19+ app.add_option (" schema" , schema_input, " JSON schema of the object" )
20+ ->check (CLI::ExistingFile);
21+ app.add_option (" object" , " JSON object to validate" )
22+ ->check (CLI::ExistingFile);
1023
1124 try {
1225 app.parse (argc, argv);
1326 } catch (const CLI::ParseError &e) {
1427 return app.exit (e);
1528 }
29+
30+ json schema{};
31+ json object{};
32+ if (!schema_input.good ())
33+ throw std::invalid_argument (" could not read schema" );
34+ if (!object_input.good ())
35+ throw std::invalid_argument (" could not read object" );
36+ schema_input >> schema;
37+ object_input >> object;
1638 return 0 ;
1739}
You can’t perform that action at this time.
0 commit comments