-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathexample.cpp
More file actions
32 lines (23 loc) · 741 Bytes
/
example.cpp
File metadata and controls
32 lines (23 loc) · 741 Bytes
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>
using namespace std;
#include "argh.h"
int main(int argc, char* argv[])
{
argh::parser cmdl;
cmdl.parse(argc, argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION);
if (cmdl["-v"])
cout << "Verbose, I am." << endl;
cout << "Positional args:\n";
for (auto& pos_arg : cmdl)
cout << '\t' << pos_arg << endl;
cout << "Positional args:\n";
for (auto& pos_arg : cmdl.pos_args())
cout << '\t' << pos_arg << endl;
cout << "\nFlags:\n";
for (auto& flag : cmdl.flags())
cout << '\t' << flag << endl;
cout << "\nParameters:\n";
for (auto& param : cmdl.params())
cout << '\t' << param.first << " : " << param.second << endl;
return EXIT_SUCCESS;
}