Skip to content

Commit 4e4c192

Browse files
committed
Add simple CLI skeleton implementation
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
1 parent 8a0b32f commit 4e4c192

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ target_sources(nlohmann_json_schema_validator PRIVATE
66
json-patch.cpp
77
string-format-check.cpp
88
)
9+
target_sources(nlohmann_json_schema_validator_cli PRIVATE
10+
cli.cpp)
11+
912
target_include_directories(nlohmann_json_schema_validator PUBLIC
1013
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
1114
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
1215
)
13-
1416
set_target_properties(nlohmann_json_schema_validator PROPERTIES
1517
PUBLIC_HEADER nlohmann/json-schema.hpp)
18+
target_link_libraries(nlohmann_json_schema_validator_cli PRIVATE
19+
nlohmann_json_schema_validator CLI11::CLI11)
1620

1721
# TODO: Why would this need to be if guarded?
1822
if (JSON_VALIDATOR_SHARED_LIBS)

src/cli.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <CLI/App.hpp>
2+
#include <CLI/Config.hpp>
3+
#include <CLI/Formatter.hpp>
4+
5+
int main(int argc, char *argv[])
6+
{
7+
CLI::App app{"Json schema validator", "json-validator"};
8+
// TODO: Move to a generated header file
9+
app.set_version_flag("--version", "2.2.0");
10+
11+
try {
12+
app.parse(argc, argv);
13+
} catch (const CLI::ParseError &e) {
14+
return app.exit(e);
15+
}
16+
return 0;
17+
}

0 commit comments

Comments
 (0)