Add simple example and improve README file.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Wed, 20 May 2015 18:58:59 +0000 (20:58 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Wed, 20 May 2015 18:58:59 +0000 (20:58 +0200)
README
docs/examples/basic/example.cpp [new file with mode: 0644]

diff --git a/README b/README
index 6166838232e757c45c0e152ffaa02c15290d5b6f..037aea026122332b3038f2b78e4b06c9931d26df 100644 (file)
--- 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 (file)
index 0000000..71e3e20
--- /dev/null
@@ -0,0 +1,27 @@
+#include <iostream>
+#include <command/command.h>
+#include <command/option.h>
+
+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<void>("-h", "Help", [](void) {
+                std::cout << "Help information\n";
+            })
+        });
+    }
+    catch(const std::exception & e) {
+        return 1;
+    }
+
+    return 0;
+}