File: example.cpp

package info (click to toggle)
argh 1.3.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 244 kB
  • sloc: cpp: 970; python: 24; makefile: 11
file content (32 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (2)
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;
}