From 774cf593d2dafc996cc643e68ae19882839ee888 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:58:59 +0200 Subject: [PATCH] Add simple example and improve README file. --- README | 17 +++++++++++++---- docs/examples/basic/example.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 docs/examples/basic/example.cpp diff --git a/README b/README index 6166838..037aea0 100644 --- a/README +++ b/README @@ -3,10 +3,11 @@ C++ library for handling command line arguments, designed to be easily used. ## Installation -1. $ ./autogen.sh -2. $ ./configure -3. $ make -4. $ sudo make install + + $ ./autogen.sh + $ ./configure + $ make + $ sudo make install ## Configuration @@ -43,3 +44,11 @@ Now program can be compiled & run using following commands: $ g++ -std=c++11 example.cpp $ ./a.out -h Help information + +## Documentation + +Current documentation can be found at: +http://dlugolecki.net.pl/software/command/docs/ + +If for some reason it is unavailable, you can build it yourself. The only +requirement is to have [Doxygen](www.doxygen.org/) installed when `make` command is invoked. diff --git a/docs/examples/basic/example.cpp b/docs/examples/basic/example.cpp new file mode 100644 index 0000000..71e3e20 --- /dev/null +++ b/docs/examples/basic/example.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +using namespace command; + +/** + * Just a simple example allowing to display help information if user will set + * command line option: -h, e.g.: + * + * ./a.out -h + * + */ +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; +} -- 2.30.2