
Hi all, I'm experimenting with program_options and trying to get something like "mandatory options". E.g. # my_prog -a someValue with "-a someValue" as mandatory options. Can I define "something" with program_options. Thanks in advantage Dejan

Dejan wrote:
Hi all,
I'm experimenting with program_options and trying to get something like "mandatory options". E.g.
# my_prog -a someValue
with "-a someValue" as mandatory options. Can I define "something" with program_options.
Try reading the documentation. The first example in the tutorial does exactly that: if (vm.count("compression")) { cout << "Compression level was set to " << vm["compression"].as<int>() << ".\n"; } else { cout << "Compression level was not set.\n"; } That's the "else" part of the test.

Dejan schrieb:
Hi all,
Hi,
I'm experimenting with program_options and trying to get something like "mandatory options". E.g.
# my_prog -a someValue
with "-a someValue" as mandatory options. Can I define "something" with program_options.
Currently it is not possible to mark an option as "mandatory", but there is something in work (Ticket #2982) to mark an option as required which will cause the library to check if the related option occured. This is planned for 1.42. Currently you have to check in your code after parsing.
Thanks in advantage
You're welcome Sascha
participants (3)
-
Dejan
-
Eric J. Holtman
-
Sascha Ochsenknecht