Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::program_options - Is is possible to enforce mandatory flag?

I'm using boost::program_options in my program. I want to make a certain flag mandatory. Is is possible to do this with program_options in a way that it'll enforce this itself? i.e., throw an error message?

like image 572
Amir Rachum Avatar asked Jan 01 '11 21:01

Amir Rachum


1 Answers

According to the documentation you can specify that an option is required in the option description:

options_description desc;
desc.add_options()
    ("help", "produce help")
    ("count", value<int>()->required(), "number of executions")
    ;
like image 85
sth Avatar answered Sep 25 '22 13:09

sth