diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 0aeb481..084055c 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,16 +1,20 @@ cmake_minimum_required(VERSION 3.10) -project(MySecondProject) +project(clientExample) # Find the shared library package find_package(Modelec COMPONENTS CLParser + TCPClient + Utils REQUIRED) # Define the executable -add_executable(MyExecutable main.cpp) +add_executable(client main.cpp) # Link the shared library to the executable -target_link_libraries(MyExecutable +target_link_libraries(client Modelec::CLParser + Modelec::TCPClient + Modelec::Utils ) \ No newline at end of file diff --git a/example/main.cpp b/example/main.cpp index d99d5d3..444ca05 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -1,19 +1,15 @@ #include #include +#include #include int main(int argc, char* argv[]) { - int port = 8080; - if (argc >= 2) { - port = std::stoi(argv[1]); - } + CLParser parser(argc, argv); - bool loggerMode = false; + int port = std::stoi(parser.getOption("port", "8080")); - if (argc >= 3) { - loggerMode = Modelec::contains(argv[2], "logger"); - } + bool loggerMode = parser.hasOption("logger"); TCPClient client("127.0.0.1", port); // Replace "127.0.0.1" with the IP address of your server and 8080 with the port number