-
Notifications
You must be signed in to change notification settings - Fork 0
/
bad.cpp
57 lines (49 loc) · 1.53 KB
/
bad.cpp
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
/*
* =====================================================================================
*
* Filename: empty.cpp
*
* Description: a gzzopts program that allows an empty comand line
*
* Version: 1.0
* Created: Friday 2014-10-31 03:24:47
* Revision: none
* Compiler: g++
*
* Author: Francis Grizzly Smit (FGJS), grizzlysmit@smit.id.au
* Organization: Me
*
* =====================================================================================
*/
#include "gzzopt.hpp"
#include <string>
int main(int argc, char* argv[]){
using namespace gzzopts;
int cnt = 0;
bool help = false;
std::string s;
Opts opt{OptionSpec(help, "show this help", "help", '?'),
OptionSpec([&cnt]() -> bool { return ++cnt; }, "increment the number of times to repeat", "count", 'c' ).set_multi(true),
};
OptionParser p(argc, argv, opt);
if(!p.good()){
std::cerr << "Error: bad opt spec" << std::endl;
return 2;
}
// parse away //
if(!p.parse()){
p.fullusage();
return 1;
}
/////////////////////////////////////////////////////////////
// //
// Use the variables that where set //
// //
/////////////////////////////////////////////////////////////
if(help){
p.fullusage();
return 0;
}
std::cout << cnt << std::endl;
return 0;
}