+## [0.3] - 2016-02-08
+### Added
+- Possibility to bind class method to parameter
+- Examples (check examples dir)
%~ \
doxyfile.stamp
-SUBDIRS = include . tests docs
+SUBDIRS = include . tests examples docs
noinst_PROGRAMS = bin/command
-AC_INIT([Command], [0.2.1], [bugz@dlugolecki.net.pl], [command], [http://dlugolecki.net.pl/software/command/])
+AC_INIT([Command], [0.3], [bugz@dlugolecki.net.pl], [command], [http://dlugolecki.net.pl/software/command/])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.10 -Wall])
AC_CONFIG_HEADERS([config.h])
include/Makefile
Makefile
tests/Makefile
+ examples/Makefile
docs/Makefile
])
+command (0.3) unstable; urgency=medium
+
+ * Possibility to bind class method to parameter
+ * New examples
+
+ -- Rafał Długołęcki <rafal@dlugolecki.net.pl> Mon, 08 Feb 2016 22:06:13 +0100
+
command (0.2.1) unstable; urgency=medium
* Initial public release.
* Added debian package building configuration
- -- Rafał Długołęcki <rafal@yggdrasil> Wed, 20 May 2015 21:52:46 +0200
+ -- Rafał Długołęcki <rafal@dlugolecki.net.pl> Wed, 20 May 2015 21:52:46 +0200
--- /dev/null
+noinst_PROGRAMS = \
+ functions \
+ methods
+
+AM_CXXFLAGS = -std=c++11
+
+functions_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ -Wall -pedantic -Wextra
+functions_SOURCES = \
+ functions.cpp
+
+methods_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ -Wall -pedantic -Wextra
+methods_SOURCES = \
+ methods.cpp
+
--- /dev/null
+#include <iostream>
+#include <string>
+#include <functional>
+
+#include "option.h"
+#include "argument.h"
+#include "required.h"
+#include "multiValue.h"
+#include "grouped.h"
+#include "command.h"
+
+using namespace command;
+
+/**
+ * @file
+ * @brief Simple example explaining how to bind functions to command-line parameters
+ */
+
+void argument_function(bool a) {
+ std::cout << "Argument: " << a << std::endl;
+}
+
+void option_function(std::string a) {
+ std::cout << "Help function " << a << std::endl;
+}
+
+void void_function(void) {
+ std::cout << "Void function " << std::endl;
+}
+
+int main(int argc, char **argv)
+{
+ try {
+ Command command(argc, argv, {
+ // function with bool parameter
+ new Argument<bool>("Input values", argument_function),
+
+ // function with std::string parameter
+ new Option<std::string>("f", "Optional file", option_function),
+
+ // function without parameter
+ new Option<void>("h", "Help", void_function)
+ });
+
+ /* Code is initialized.
+ *
+ * You can run your main program e.g. here
+ */
+ }
+ catch(const std::exception & e) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}
--- /dev/null
+#include <iostream>
+#include <string>
+#include <functional>
+
+#include "option.h"
+#include "argument.h"
+#include "required.h"
+#include "multiValue.h"
+#include "grouped.h"
+#include "command.h"
+
+using namespace command;
+
+/**
+ * @file
+ * @brief Simple example explaining how to bind class methods to command-line parameters
+ */
+
+class ExampleClass {
+public:
+ void _argument(bool a) {
+ std::cout << "Argument: " << a << std::endl;
+ }
+ void _option(std::string a) {
+ std::cout << "Help function " << a << std::endl;
+ }
+ void _void(void) {
+ std::cout << "Void function " << std::endl;
+ }
+};
+
+int main(int argc, char **argv)
+{
+ ExampleClass c;
+
+ try {
+ Command command(argc, argv, {
+ // class method with bool parameter
+ new Argument<bool>("Input values", std::bind(&ExampleClass::_argument, &c, std::placeholders::_1)),
+
+ // class method std::string parameter
+ new Option<std::string>("f", "Optional file", std::bind(&ExampleClass::_option, &c, std::placeholders::_1)),
+
+ // class method without parameter
+ new Option<void>("h", "Help", std::bind(&ExampleClass::_void, &c))
+ });
+
+ /* Code is initialized.
+ *
+ * You can run your main program for example here
+ */
+ }
+ catch(const std::exception & e) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return 0;
+}