-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
57 lines (42 loc) · 1.53 KB
/
test.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "argparser.h"
int main(int argc, char* argv[])
{
bool hello_parsed = false;
bool age_parsed = false;
bool long_parsed = false;
bool ken_parsed = false;
int m_age;
argparser m_argparse(argc, argv);
m_argparse.set_usage_info("./test [option] <value> ..");
m_argparse.set_header_info("Simple program v0.0.1.");
m_argparse.set_footer_info("Developed by kenneth buchunju\n"
"(C) 2020 <buchunjukenneth@gmail.com>.");
m_argparse.add_option_group("General options.");
m_argparse.add_option("hello","hl",&hello_parsed, "A simple hello greeting", false);
m_argparse.add_option_group("Haha options.");
m_argparse.add_option("age", "a", &age_parsed, A_INT, (void*)&m_age, "Age of the user",true);
m_argparse.add_option("long","l",&long_parsed,
"This is a very long line to test the length of the option description. "
"Just for testing purposes. It can be as long as possible",false);
m_argparse.add_option_group("Hehe options.");
m_argparse.add_option("ken","k", &ken_parsed, "Doing something.", false);
m_argparse.parse();
if(hello_parsed)
{
/* Say hello */
std::cout << "Hello" << std::endl;
}
if(age_parsed)
{
std::cout << "Your age is: " << m_age << std::endl;
}
if(ken_parsed)
{
std::cout << "Ken was here." << std::endl;
}
if(long_parsed)
{
std::cout << "mmmmh. Am speechless" << std::endl;
}
return 0;
}