C++ 命令行界面 clipp

码农软件 · 软件分类 · 其他开发相关 · 2019-10-16 12:14:23

软件介绍

clipp 是一个现代 C++ 的命令行界面。它易于使用,功能强大,支持 C++ 11/14/17,且项目仅集成在单个头文件中的。

功能支持选项、选项+值、文档路径值、位置命令、嵌套替代、决策树、可连接标志、自定义值过滤等,此外还有文档生成(使用行、手册页)与错误处理。

简单使用示例:

以这个命令行界面为例:

SYNOPSIS
    convert <input file> [-r] [-o <output format>] [-utf16]

OPTIONS
    -r, --recursive  convert files recursively
    -utf16           use UTF-16 encoding

代码定义了 input file 和三个选项:-r-o 和 -utf16。如果解析失败,默认使用文档页代码片段将打印到 stdout。

#include <iostream>
#include "clipp.h"
using namespace clipp; using std::cout; using std::string;

int main(int argc, char* argv[]) { 
    bool rec = false, utf16 = false;
    string infile = "", fmt = "csv";

    auto cli = (
        value("input file", infile),
        option("-r", "--recursive").set(rec).doc("convert files recursively"),
        option("-o") & value("output format", fmt),
        option("-utf16").set(utf16).doc("use UTF-16 encoding")
    );

    if(!parse(argc, argv, cli)) cout << make_man_page(cli, argv[0]);
    // ...
}

本文地址:https://codercto.com/soft/d/16877.html

The Art of UNIX Programming

The Art of UNIX Programming

Eric S. Raymond / Addison-Wesley / 2003-10-3 / USD 54.99

Writing better software: 30 years of UNIX development wisdom In this book, five years in the making, the author encapsulates three decades of unwritten, hard-won software engineering wisdom. Raymond b......一起来看看 《The Art of UNIX Programming》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具