@@ -30,10 +30,12 @@ int main(int argc, char* argv[]) {
30
30
// add options
31
31
// options can be short, long, or both (short must come first)
32
32
// for example: options.exe -e OR options.exe --evan
33
- options.add_options ()(" e,evan" , " Prints a message from Evan." )(
34
- " c,craig" , " Prints a message from Craig." )(
35
- " h,help" , " Prints helpful information." )(
36
- " i,integer" , " Gets an integer from user." , value<int >());
33
+ options.add_options ()
34
+ (" e,evan" , " Prints a message from Evan." )
35
+ (" c,craig" , " Prints a message from Craig." )
36
+ (" h,help" , " Prints helpful information." )
37
+ (" i,integer" , " Gets an integer from user." , value<int >())
38
+ (" d,double" , " Gets a double from user." , value<double >());
37
39
38
40
// parse options
39
41
auto result = options.parse (argc, argv);
@@ -43,7 +45,7 @@ int main(int argc, char* argv[]) {
43
45
if (result.count (" evan" ) > 0 )
44
46
print (" Hello, my name is Evan!" );
45
47
46
- if (result.count (" craig " ) > 0 )
48
+ if (result.count (" c " ) > 0 )
47
49
print (" Hello, my name is Craig!" );
48
50
49
51
if (result.count (" help" ) > 0 )
@@ -54,5 +56,10 @@ int main(int argc, char* argv[]) {
54
56
print (" You entered " + stringify (i));
55
57
}
56
58
59
+ if (result.count (" d" ) > 0 ) {
60
+ double d = result[" d" ].as <double >();
61
+ print (" You entered " + stringify (d));
62
+ }
63
+
57
64
return 0 ;
58
65
}
0 commit comments