epr24pr5-ojanssen2/main.cpp

35 lines
780 B
C++

#include "std_lib_inc.h"
#include "parameter_reader.h"
#include "SubCommand.h"
#include "HelpCommand.h"
#include "AddCommand.h"
using commands::SubCommand;
using commands::HelpCommand;
using commands::AddCommand;
const vector<SubCommand*> handlers = { new HelpCommand(), new AddCommand() };
// Mein Leben auf IMDB, nur 7/10.
int main(int argc, char** argv)
{
if (argc < 2) {
cout << "There are not enough args!\n";
return 0;
}
stringstream parameter = make_string_stream(argc, argv);
string command;
parameter >> command;
for (SubCommand* sc : handlers) {
if (sc->get_name() == command) {
sc->run(argc, parameter);
return 0;
}
}
cout << "I don't know this command!\n";
return 0;
}