mirror of
https://github.com/modelec/cpp-lib.git
synced 2026-01-19 08:37:22 +01:00
initial commit
This commit is contained in:
26
example/main.cpp
Normal file
26
example/main.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <Modelec/CLParser.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
CLParser parser(argc, argv);
|
||||
|
||||
if (parser.hasOption("help")) {
|
||||
std::cout << "Usage: " << parser.getPositionalArgument(0) << " [options]" << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
std::cout << " --help: Display this help message" << std::endl;
|
||||
std::cout << " --port <port>: Set the port to listen to" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::optional<std::string> port = parser.getOption("port");
|
||||
|
||||
if (port.has_value()) {
|
||||
std::cout << port.value() << std::endl;
|
||||
} else {
|
||||
std::cout << "No port specified" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user