2016-03-12 17:58:01 +00:00
|
|
|
#include "shell.h"
|
2016-03-11 14:49:24 +00:00
|
|
|
|
2016-03-12 17:58:01 +00:00
|
|
|
Shell::Commands::Commands()
|
2016-03-11 14:49:24 +00:00
|
|
|
{
|
|
|
|
if(created) throw CommandsAlreadyCreatedException();
|
|
|
|
created=true;
|
|
|
|
}
|
|
|
|
|
2016-03-12 17:58:01 +00:00
|
|
|
void Shell::Commands::add(Command* cmd){
|
2016-03-11 14:49:24 +00:00
|
|
|
commands.push_back(cmd);
|
|
|
|
}
|
|
|
|
|
2016-03-12 17:58:01 +00:00
|
|
|
size_t Shell::Commands::howMany(){
|
2016-03-11 14:49:24 +00:00
|
|
|
return commands.size();
|
|
|
|
}
|
|
|
|
|
2016-03-12 17:58:01 +00:00
|
|
|
int Shell::Commands::launch(const vector<string>* args){
|
2016-03-11 16:45:15 +00:00
|
|
|
for(unsigned int i=0; i<commands.size(); i++){
|
2016-03-11 14:49:24 +00:00
|
|
|
if((commands[i]->getName())==args->operator [](0)){
|
|
|
|
return commands[i]->execute(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw CommandNotFoundException();
|
|
|
|
}
|
|
|
|
|
2016-03-12 17:58:01 +00:00
|
|
|
bool Shell::Commands::created = false;
|
2016-03-11 14:49:24 +00:00
|
|
|
|
|
|
|
|