forked from ratanparai/cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 92
/
main_flags_absl.cc
32 lines (27 loc) · 921 Bytes
/
main_flags_absl.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
/**
* Example main file for C++ starter template
* showcasing Abseil's flags library
* By: Ari Saif
*/
#include <iostream>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/flags/usage.h"
ABSL_FLAG(bool, verbose, false,
"Include 'advanced' options in the menu listing");
ABSL_FLAG(std::string, message, "Hello world!", "Message to print");
ABSL_FLAG(uint32_t, year, 2020, "Current year");
ABSL_FLAG(std::vector<std::string>, names,
std::vector<std::string>({"jack", "jim", "jamal"}),
"comma-separated list of names the program accepts");
int main(int argc, char *argv[]) {
// absl::SetProgramUsageMessage("--massage: custom message");
absl::ParseCommandLine(argc, argv);
if (absl::GetFlag(FLAGS_verbose)) {
std::cout << "Verbose "
<< ": ";
}
std::cout << absl::GetFlag(FLAGS_message) << std::endl;
return 0;
}