浮生愿,不曾解,我还有一些念,向桃花的尽头追~|

园龄:粉丝:关注:

2025-01-14 17:22阅读: 5评论: 0推荐: 0

clipp示例

clipp/1.2.3

#include <iostream>
#include <string>
#include <clipp.h>
# define __VERSION "0.0.0.1"
int main(int argc, char* argv[]) {
bool help = false;
bool version = false;
std::string input_file;
std::string output_file;
auto cli = (
// 定义一个帮助标志,使用 -h 或 --help
clipp::option("-h", "--help").set(help).doc("Show help information"),
// 定义一个输入文件选项,使用 -i 或 --input
clipp::option("-i", "--input").doc("Input file") & clipp::value("file", input_file),
// 定义一个输出文件选项,使用 -o 或 --output
clipp::option("-o", "--output").doc("Output file") & clipp::value("file", output_file),
// 定义一个整数值选项,使用 -v 或 --value
clipp::option("-v", "--value").set(version).doc("Show version")
);
if (clipp::parse(argc, argv, cli)) {
if (help) {
std::cout << clipp::make_man_page(cli, argv[0]);
}else if(version){
std::cout << "Version: " << __VERSION << std::endl;
}
else {
std::cout << "Input file: " << input_file << std::endl;
std::cout << "Output file: " << output_file << std::endl;
}
} else {
std::cerr << clipp::make_man_page(cli, argv[0]);
return 1;
}
return 0;
}

本文作者:料峭春风吹酒醒

本文链接:https://www.cnblogs.com/pengpengda/p/18671236

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   料峭春风吹酒醒  阅读(5)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起