blob: 991c2c95aa8bdc3a9475ebd4275344e1b01c3d34 (
plain)
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
58
59
60
61
62
|
// file : examples/features/driver.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#include <iostream>
#include <iterator>
#include <algorithm>
#include "options.hxx"
using namespace std;
int
main (int argc, char* argv[])
{
try
{
features::options o (argc, argv);
// --out-dir | -o
//
if (!o.out_dir ().empty ())
cerr << "output dir: " << o.out_dir () << endl;
// --first-name & --last-name
//
cerr << "first name: " << o.first_name () << endl
<< "last name : " << o.last_name () << endl;
// --vector | -v & --set | -s
//
if (!o.vector ().empty ())
{
copy (o.vector ().begin (), o.vector ().end (),
ostream_iterator<int> (cerr, " "));
cerr << endl;
}
if (!o.set ().empty ())
{
copy (o.set ().begin (), o.set ().end (),
ostream_iterator<int> (cerr, " "));
cerr << endl;
}
// --map | -m
//
typedef map<std::string, std::string> str_map;
const str_map& m = o.map ();
str_map::const_iterator i (m.find ("a"));
if (i != m.end ())
cerr << "value for the 'a' key: " << i->second << endl;
}
catch (const cli::exception& e)
{
cerr << e << endl;
return 1;
}
}
|