Command(unsigned int argc, char *argv[], std::initializer_list<Parameter *> params)
: args(params) {
for(Parameter *param : params) {
- std::cout << "Command foreach" << std::endl;
param->handle();
}
}
*/
template<typename OptionType>
class Option
- : Argument<OptionType> {
+ : public Argument<OptionType> {
public:
// typedef typename Argument<OptionType, Lambda>::FunctionType FunctionType;
protected:
virtual ~Option() { }
virtual void handle() {
+ std::cout << "Option::handle()" << std::endl;
+ this->call(std::string("O"));
}
};
}
#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<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }),
- new command::Argument<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }),
- new command::Argument<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }),
- new command::Argument<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }),
- new command::Argument<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; })
+ new command::Argument<std::string>("File path", some_function),
+ new command::Option<std::string>("h", "Help", some_function)
});
return 0;