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 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!