2025-02-09 19:58:55 +01:00
|
|
|
#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
|
|
|
|
{
|
2025-02-09 22:30:03 +01:00
|
|
|
ShowCommand::ShowCommand() : SubCommand("show", false)
|
2025-02-09 19:58:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-02-09 21:14:26 +01:00
|
|
|
void ShowCommand::run(stringstream& args)
|
2025-02-09 19:58:55 +01:00
|
|
|
{
|
2025-02-09 23:22:43 +01:00
|
|
|
Manager* mgr = Manager::get_instance();
|
2025-02-09 19:58:55 +01:00
|
|
|
const string data_type = Util::read_string(args);
|
|
|
|
if (data_type == "user")
|
2025-02-09 23:22:43 +01:00
|
|
|
for (User* u : mgr->get_users()) {
|
2025-02-09 19:58:55 +01:00
|
|
|
AddUser au = {*u};
|
|
|
|
cout << au;
|
|
|
|
}
|
|
|
|
else if (data_type == "task")
|
2025-02-09 23:22:43 +01:00
|
|
|
for (Task* t : mgr->get_tasks()) {
|
2025-02-09 19:58:55 +01:00
|
|
|
AddTask at = {*t};
|
|
|
|
cout << at;
|
|
|
|
}
|
|
|
|
else
|
2025-02-09 21:33:42 +01:00
|
|
|
throw Error(102, "Ein Parameter eines Befehls konnte nicht gelesen werden");
|
2025-02-09 19:58:55 +01:00
|
|
|
}
|
|
|
|
} // commands
|