【C++】C++11 的命令行分析器

【github】CLI11
一. 配置
1.在main函数中增加

#include "CLI11.hpp"

2.将 CLI11.hpp 添加到路径下

可以直接从这里下载https://download.csdn.net/download/weixin_50862344/87900168

二. 使用
app.add_option(“-f”, filename, “test”);只要不写-h都行哈哈哈

#include "CLI11.hpp"
#include <iostream>

int main(int argc, const char* argv[]) {
    
    

    CLI::App app{
    
    "App description"};

    std::string filename = "default";

    app.add_option("-f", filename, "test");
    std::cout<< "1"<<std::endl;

    CLI11_PARSE(app, argc, argv);
    std::cout<< "filename"<<filename <<std::endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_50862344/article/details/131177344