msh-console/commands.cpp

28 lines
580 B
C++

#include "shell.h"
Shell::Commands::Commands()
{
if(created) throw CommandsAlreadyCreatedException();
created=true;
}
void Shell::Commands::add(Command* cmd){
commands.push_back(cmd);
}
size_t Shell::Commands::howMany(){
return commands.size();
}
int Shell::Commands::launch(const vector<string>* args){
for(unsigned int i=0; i<commands.size(); i++){
if((commands[i]->getName())==args->operator [](0)){
return commands[i]->execute(args);
}
}
throw CommandNotFoundException();
}
bool Shell::Commands::created = false;