From 4e4c192c87cfcadd8b71bf1e708e2d93c5bcd5d1 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Wed, 10 May 2023 11:22:55 +0200 Subject: [PATCH] Add simple CLI skeleton implementation Signed-off-by: Cristian Le --- src/CMakeLists.txt | 6 +++++- src/cli.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/cli.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f895d66..a3e2dbc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,13 +6,17 @@ target_sources(nlohmann_json_schema_validator PRIVATE json-patch.cpp string-format-check.cpp ) +target_sources(nlohmann_json_schema_validator_cli PRIVATE + cli.cpp) + target_include_directories(nlohmann_json_schema_validator PUBLIC $ $ ) - set_target_properties(nlohmann_json_schema_validator PROPERTIES PUBLIC_HEADER nlohmann/json-schema.hpp) +target_link_libraries(nlohmann_json_schema_validator_cli PRIVATE + nlohmann_json_schema_validator CLI11::CLI11) # TODO: Why would this need to be if guarded? if (JSON_VALIDATOR_SHARED_LIBS) diff --git a/src/cli.cpp b/src/cli.cpp new file mode 100644 index 0000000..94519eb --- /dev/null +++ b/src/cli.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + CLI::App app{"Json schema validator", "json-validator"}; + // TODO: Move to a generated header file + app.set_version_flag("--version", "2.2.0"); + + try { + app.parse(argc, argv); + } catch (const CLI::ParseError &e) { + return app.exit(e); + } + return 0; +}