c++ - Boost::program_options - print usage if no inputs provided -


i trying use boost program_options in order parse program inputs. in general docs provide necessary info parsing. however, make program print usage instructions when no inputs provided , can't seem figure out. there not seem "default" options nor can find how count number of inputs provided (to test).

this code @ moment:

boost::program_options::options_description help("usage"); help.add_options()     ("help", "print info");  boost::program_options::options_description req("required inputs"); req.add_options()     ("root", boost::program_options::value<std::string>(&images_root), "root directory")  boost::program_options::options_description opt("option inputs"); opt.add_options()     ("verbose", boost::program_options::value<bool>(&verbose)->implicit_value(1), "verbose");  boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, all), vm); if (vm.count("help")) {     std::cout << help;     return 1; }  boost::program_options::notify(vm); 

how can produce following (i.e. if no inputs std::cout << help)?

./test-file >> print info 

you argc

for example:

int main(int argc, char** argv) {     if( argc <= 1 )       std::cout << "print usage\n";    return 0; } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -