-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
32 lines (26 loc) · 797 Bytes
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <gflags/gflags.h>
#include <glog/logging.h>
static bool ValidatePort(const char* flagname, gflags::int32 value)
{
if (value > 0 && value < 32768)
{
return true;
}
return false;
}
DEFINE_int32(port, 9527, "What port to listen on");
DEFINE_validator(port, &ValidatePort);
DEFINE_bool(debug, false, "Turn on the debug mode");
int main(int argc, char* argv[])
{
// parse command line parameters
gflags::ParseCommandLineFlags(&argc, &argv, true);
// ./example --port=80 --debug
std::cout << "port = " << FLAGS_port << std::endl;
std::cout << "debug = " << std::boolalpha << FLAGS_debug << std::endl;
// Initialize the log
google::InitGoogleLogging(argv[0]);
CHECK_LE(5, 6);
LOG(ERROR) << "Hello, World!";
}