Command, 一个C++库用于处理命令行参数
Command, 一个C++库用于处理命令行参数。
Installation
debian package
$ wget https://github.com/quayle/command/releases/download/v0.2.1-deb/command_0.2.1_all.deb $ sudo dpkg -i command_0.2.1_all.deb
from sources
You will need to have autotools installed (automake, autoconf, ...)
$ ./autogen.sh $ ./configure $ make $ sudo make install
Configuration
You need to enable c++11 support in your compiler. You can achieve that in g++ and clang++ by adding-std=c++11compilation flag.
As this is header-only library, you don't need any additional steps.
Usage
example.cpp:
#include <iostream> #include <command/command.h> #include <command/option.h> using namespace command; int main(int argc, char *argv[]) { try { Command command(argc, argv, { new Option<void>("-h", "Help", [](void) { std::cout << "Help information\n"; }) }); } catch(const std::exception & e) { return 1; } return 0; }
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!