From: Rafał Długołęcki Date: Wed, 20 May 2015 18:30:10 +0000 (+0200) Subject: Improve README. X-Git-Tag: v0.2.1~5 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=0ae623f14cc12a0c788b6b898d1e81a3d34860c4;p=command.git Improve README. --- diff --git a/README b/README index 0bb82e9..6166838 100644 --- a/README +++ b/README @@ -1,18 +1,45 @@ -Command, a C++ library for handling command line arguments +# Command -Designing to be used like follows: +C++ library for handling command line arguments, designed to be easily used. -Example: +## Installation +1. $ ./autogen.sh +2. $ ./configure +3. $ make +4. $ sudo make install - void some_function(std::string str) { - std::cout << "Some function" << std::endl; +## Configuration + +You need to enable c++11 support in your compiler. You can achieve that in +g++ and clang++ by adding `-std=c++11` compilation flag. + +As this is header-only library, you don't need any additional steps. + +## Usage + +example.cpp: + + #include + #include + #include + + using namespace command; + + int main(int argc, char *argv[]) { + try { + Command command(argc, argv, { + new Option("-h", "Help", [](void) { std::cout << "Help information\n"; }) + }); + } + catch(const std::exception & e) { + return 1; + } + + return 0; } - command::Command command(argc, argv, { - command::Option("f", "File path", [](std::string value)->void { cout << "Sth: " << value << endl; }), - command::Argument("File path", []()->void { cout << "Sth: " << value << endl; }), - command::Option("help", "Help description", [](void)->void { cout << "Sth: " << value << endl; }), - command::Option("verbose", "Verbose option description", &myClass->verbose), - command::Option("verbose", "Verbose option description", some_function) - }); +Now program can be compiled & run using following commands: + $ g++ -std=c++11 example.cpp + $ ./a.out -h + Help information