- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
Latest commit
23 lines (20 loc) · 684 Bytes
/
Copy pathexample.cpp
File metadata and controls
23 lines (20 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include"flags.hpp"
structexample_option
{
std::string ip{};
uint16_t port{ 6014 };
bool keep_alive{ false };
};
intmain(int argc, char** argv)
{
auto opts = flags<example_option>("flags example v1.0", {
{ "-ip", "ip address, like 192.168.1.14", &example_option::ip },
{ "-port", "port, default is 6014", &example_option::port },
{ "-keepalive", "keep alive, default is false", &example_option::keep_alive },
})(argc, argv);
std::cout << "options: " << ".ip=" << opts.ip << ", "
<< ".port=" << opts.port
<< ", " << ".keep_alive=" << std::boolalpha << opts.keep_alive
<< std::endl;
}