epr24pr5-ojanssen2/ShowCommand.cpp
moonleay 9749953ed7
feat: finished implementing stubs in Manager
fix: fixed initial problems with impl
2025-02-09 21:14:26 +01:00

36 lines
850 B
C++

#include "ShowCommand.h"
#include "Error.h"
#include "Util.h"
#include "Manager.h"
using util::Manager;
using util::Util;
using models::AddUser;
using models::AddTask;
using err::Error;
namespace commands
{
ShowCommand::ShowCommand() : SubCommand("show", 100, false)
{
}
void ShowCommand::run(stringstream& args)
{
Manager& mgr = Manager::get_instance();
const string data_type = Util::read_string(args);
if (data_type == "user")
for (User* u : mgr.get_users()) {
AddUser au = {*u};
cout << au;
}
else if (data_type == "task")
for (Task* t : mgr.get_tasks()) {
AddTask at = {*t};
cout << at;
}
else
throw Error(101, "Befehl ist unbekannt.");
}
} // commands