2025-02-09 19:58:55 +01:00
|
|
|
#pragma once
|
|
|
|
#include "ActiveCommand.h"
|
2025-02-05 12:48:05 +01:00
|
|
|
#include "AddCommand.h"
|
2025-02-09 19:58:55 +01:00
|
|
|
#include "AssignCommand.h"
|
|
|
|
#include "DelCommand.h"
|
|
|
|
#include "Error.h"
|
2025-02-10 00:49:31 +01:00
|
|
|
#include "HelpCommand.h"
|
2025-02-09 19:58:55 +01:00
|
|
|
#include "ListCommand.h"
|
2025-02-10 00:49:31 +01:00
|
|
|
#include "ShowCommand.h"
|
2025-02-09 19:58:55 +01:00
|
|
|
#include "UnassignCommand.h"
|
2025-02-10 00:49:31 +01:00
|
|
|
#include "parameter_reader.h"
|
|
|
|
#include "std_lib_inc.h"
|
2025-02-05 12:48:05 +01:00
|
|
|
|
|
|
|
using commands::SubCommand;
|
|
|
|
using commands::HelpCommand;
|
|
|
|
using commands::AddCommand;
|
2025-02-09 19:58:55 +01:00
|
|
|
using commands::ListCommand;
|
|
|
|
using commands::DelCommand;
|
|
|
|
using commands::AssignCommand;
|
|
|
|
using commands::UnassignCommand;
|
|
|
|
using commands::ActiveCommand;
|
2025-02-10 00:49:31 +01:00
|
|
|
using commands::ShowCommand;
|
2025-02-09 19:58:55 +01:00
|
|
|
using err::Error;
|
|
|
|
|
|
|
|
const vector<SubCommand*> handlers = {
|
|
|
|
new HelpCommand(),
|
|
|
|
new AddCommand(),
|
|
|
|
new ListCommand(),
|
|
|
|
new DelCommand(),
|
|
|
|
new AssignCommand(),
|
|
|
|
new UnassignCommand(),
|
|
|
|
new ActiveCommand(),
|
2025-02-10 00:49:31 +01:00
|
|
|
new ShowCommand(),
|
2025-02-09 19:58:55 +01:00
|
|
|
};
|
2025-02-05 12:48:05 +01:00
|
|
|
|
2025-01-16 15:29:59 +01:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2025-02-10 14:57:47 +01:00
|
|
|
//TODO:: THis needs to be removed?
|
2025-02-09 19:58:55 +01:00
|
|
|
if (argc < 2)
|
|
|
|
{
|
2025-02-05 12:48:05 +01:00
|
|
|
cout << "There are not enough args!\n";
|
|
|
|
return 0;
|
|
|
|
}
|
2025-02-09 12:34:07 +01:00
|
|
|
|
2025-02-05 12:48:05 +01:00
|
|
|
stringstream parameter = make_string_stream(argc, argv);
|
|
|
|
string command;
|
|
|
|
parameter >> command;
|
|
|
|
|
2025-02-09 19:58:55 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
for (SubCommand* sc : handlers)
|
|
|
|
{
|
|
|
|
if (sc->get_name() == command)
|
|
|
|
{
|
2025-02-09 21:14:26 +01:00
|
|
|
sc->run(parameter);
|
|
|
|
if (sc->should_display_result())
|
2025-02-09 21:43:27 +01:00
|
|
|
cout << "100: Alles erfolgreich\n";
|
2025-02-09 21:23:48 +01:00
|
|
|
return 0;
|
2025-02-09 12:34:07 +01:00
|
|
|
}
|
2025-02-05 12:48:05 +01:00
|
|
|
}
|
|
|
|
}
|
2025-02-09 19:58:55 +01:00
|
|
|
catch (Error& e)
|
2025-02-09 12:34:07 +01:00
|
|
|
{
|
2025-02-09 21:43:27 +01:00
|
|
|
cout << e.get_nr() << ": " << e.what() << "\n";
|
2025-02-09 21:23:48 +01:00
|
|
|
return 0;
|
2025-02-09 12:34:07 +01:00
|
|
|
}
|
2025-02-09 21:43:27 +01:00
|
|
|
cout << "101: Befehl ist unbekannt.\n";
|
2025-02-09 21:23:48 +01:00
|
|
|
return 0;
|
2025-01-16 15:29:59 +01:00
|
|
|
}
|