mirror of
https://github.com/modelec/cpp-lib.git
synced 2026-01-18 16:17:22 +01:00
example clParser
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -1,19 +1,15 @@
|
||||
#include <Modelec/TCPClient.h>
|
||||
#include <Modelec/Utils.h>
|
||||
#include <Modelec/CLParser.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user