We come across this sort of problem here regularly. However the issue is more general in that there are often sets of options that are required together. In the example above you may only require the output if the input is specified.

If you accept that your use case is just a specific form of the more general use case, you can see that it is much easier to add your own code to decide on argument validity after calling vul_parse_args().


There is some support in vul_args for this approach -

e.g. in your example above
...
vul_parse_args(argc, argv);
if (!input_filename.set())
 display_usage_and_exit("Must specify --input");
if (!output_filename.set())
 display_usage_and_exit("Must specify --output");


Ian.

Amitha, nope, that does not make a required argument, only a named one. I'd still have to check manually for if it was given.

Ian, checking .set() will definitely work, but if there are a bunch of required options that is  just a long chunk of code to check all of them. I thought it would just be easier if you could say
vul_arg<std::string> a_filename("--input", "Input filename?", required);

and the .set() check would be performed automatically. Then for the "general" case you mentioned (groups of required inputs), you could do the checking manually.

Just my $.02.

Dave