Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Basic cli #268

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add simple CLI skeleton implementation
Signed-off-by: Cristian Le <[email protected]>
LecrisUT committed May 11, 2023
commit 4e4c192c87cfcadd8b71bf1e708e2d93c5bcd5d1
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

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)
17 changes: 17 additions & 0 deletions src/cli.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <CLI/App.hpp>
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>

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;
}