forked from University/epr24pr5-ojanssen2
34 lines
879 B
C++
34 lines
879 B
C++
#include "ListCommand.h"
|
|
|
|
#include "Error.h"
|
|
#include "Manager.h"
|
|
|
|
using util::Manager;
|
|
using models::User;
|
|
using models::Task;
|
|
using models::Assignment;
|
|
using err::Error;
|
|
|
|
namespace commands
|
|
{
|
|
ListCommand::ListCommand() : SubCommand("list", false)
|
|
{
|
|
}
|
|
|
|
void ListCommand::run(stringstream& args)
|
|
{
|
|
Manager* mgr = Manager::get_instance();
|
|
const string data_type = Util::read_string(args);
|
|
if (data_type == "users")
|
|
for (const User* u : mgr->get_users())
|
|
cout << *u;
|
|
else if (data_type == "tasks")
|
|
for (const Task* t : mgr->get_tasks())
|
|
cout << *t;
|
|
else if (data_type == "assignments")
|
|
for (const Assignment* a : mgr->get_assignments())
|
|
cout << *a;
|
|
else
|
|
throw Error(101, "Befehl ist unbekannt.");
|
|
}
|
|
} // commands
|