From 0ae623f14cc12a0c788b6b898d1e81a3d34860c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Wed, 20 May 2015 20:30:10 +0200 Subject: [PATCH] Improve README. --- README | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) 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 -- 2.30.2