Ticket #7256: minipo.cc

File minipo.cc, 680 bytes (added by Georg Sauthoff <mail@…>, 9 years ago)

minimal example

Line 
1#include <iostream>
2using namespace std;
3#include <boost/program_options.hpp>
4namespace po = boost::program_options;
5
6int main(int argc, char **argv)
7{
8 po::options_description desc("Options");
9 desc.add_options()
10 ("help", "this help screen")
11 ("foo-1", po::value<int>(), "foo")
12 ("bar-2", po::value<int>(), "bar")
13 ;
14 po::variables_map vm;
15 po::store(po::parse_command_line(argc, argv, desc), vm);
16 po::notify(vm);
17 if (vm.count("help")) {
18 cout << desc << "\n";
19 return 0;
20 }
21 cout << "count(foo-1)=" << vm.count("foo-1") << '\n'
22 << "count(1)=" << vm.count("1") << '\n'
23 << "count(bar-2)=" << vm.count("bar-2") << '\n';
24 return 0;
25}