From: Rafał Długołęcki Date: Sun, 26 Apr 2015 06:27:31 +0000 (+0200) Subject: Fixed Option parameter. Added new example. X-Git-Tag: v0.2~42 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=31ae5119e64fade1e8415fcc51265e199a9a447f;p=command.git Fixed Option parameter. Added new example. --- diff --git a/include/command.h b/include/command.h index f53227e..9cf0a9f 100644 --- a/include/command.h +++ b/include/command.h @@ -27,7 +27,6 @@ namespace command { Command(unsigned int argc, char *argv[], std::initializer_list params) : args(params) { for(Parameter *param : params) { - std::cout << "Command foreach" << std::endl; param->handle(); } } diff --git a/include/option.h b/include/option.h index fe0fc85..fef4e31 100644 --- a/include/option.h +++ b/include/option.h @@ -15,7 +15,7 @@ namespace command { */ template class Option - : Argument { + : public Argument { public: // typedef typename Argument::FunctionType FunctionType; protected: @@ -38,6 +38,8 @@ namespace command { virtual ~Option() { } virtual void handle() { + std::cout << "Option::handle()" << std::endl; + this->call(std::string("O")); } }; } diff --git a/src/main.cpp b/src/main.cpp index 80aeb27..1cc8387 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,14 +5,15 @@ #include "argument.h" #include "command.h" +void some_function(std::string str) { + std::cout << "Some function" << std::endl; +} int main(int argc, char *argv[]) { command::Command command(argc, argv, { new command::Argument("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }), - new command::Argument("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }), - new command::Argument("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }), - new command::Argument("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }), - new command::Argument("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }) + new command::Argument("File path", some_function), + new command::Option("h", "Help", some_function) }); return 0;