-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (35 loc) · 1.07 KB
/
Copy pathmain.cpp
File metadata and controls
48 lines (35 loc) · 1.07 KB
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
#include <iostream>
#include "lib/cli-parser/app.h"
using namespace std;
void doc(){
cout << "Say hello with style" << endl;
cout << "Usage : hello hello [OPTIONS]" << endl << endl;
cout << "Options : " << endl;
cout << '\t' << "--name=NAME," << '\t' << "Replace 'world' by NAME in the message" << endl;
cout << '\t' << "-l," << '\t' << "--love" << '\t' << "Display hearts at the end of the message" << endl;
}
int main(int argc, char *argv[])
{
Cli::App app = Cli::App(argc, argv);
if(app.arg(0) == "hello"){
if(app.hasOption("version")){
cout << "Hello version 1.0" << endl;
return 0;
}
if(app.hasOption("help")){
doc();
return 0;
}
if(app.option("name") != ""){
cout << "Hello " << app.option("name") << "!" << endl;
}else{
cout << "Hello World!" << endl;
}
if(app.hasOption("love") || app.hasFlag("l")){
cout << "<3 <3 <3 <3 <3 <3 <3" << endl;
}
}else{
doc();
}
return 0;
}