#include <iostream>
#include <string>
#include <boost/program_options.hpp>

int main(int argc,char **argv)
{
    namespace po = boost::program_options;

    po::option_description desc("allowed options");

    desc.add_options()
        ("help,h",        "help message")
        ("version,v",    "display verison")
        ;

    po::variables_map vm;
    po::store(po::parse_command_line(argc,argv,desc),vm);
    po::notify(vm);

    if (vm.count("help"))
    {
        std::cout<<desc<<std::endl;
        return 0;
    }

    if (vm.count("version"))
    {
        std::cout<<"version 0.0.1"<<std::endl;
        return 0;
    }

    std::cout<<"exec program"<<std::endl;
    return 0;

}

相关文章:

  • 2021-09-10
  • 2021-10-13
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-06-05
  • 2021-10-26
猜你喜欢
  • 2021-12-09
  • 2021-11-18
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案