forked from University/epr24pr5-ojanssen2
34 lines
869 B
C++
34 lines
869 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", 100, true)
|
|
{
|
|
}
|
|
|
|
void ListCommand::run(int argc, 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())
|
|
cout << *u;
|
|
else if (data_type == "task")
|
|
for (Task* t : mgr.get_tasks())
|
|
cout << *t;
|
|
else if (data_type == "assignment")
|
|
for (Assignment* a : mgr.get_assignments())
|
|
cout << *a;
|
|
else
|
|
throw Error(101, "Befehl ist unbekannt.");
|
|
}
|
|
} // commands
|