27 lines
769 B
C++
27 lines
769 B
C++
|
#include "shell.h"
|
||
|
|
||
|
Shell::Commands::Commands(Shell* s) : commands(), threadCommands()
|
||
|
{
|
||
|
parent = s;
|
||
|
}
|
||
|
|
||
|
void Shell::Commands::add(Command* cmd, bool isthread){
|
||
|
if(!isthread) commands.push_back(cmd);
|
||
|
else threadCommands.push_back(cmd);
|
||
|
}
|
||
|
|
||
|
size_t Shell::Commands::howMany() const{
|
||
|
return commands.size();
|
||
|
}
|
||
|
|
||
|
int Shell::Commands::launch(const vector<string>* args, bool launchThread){
|
||
|
for(unsigned int i=0; i<(launchThread ? threadCommands.size() : commands.size()); i++){
|
||
|
if((launchThread ? threadCommands[i]->getName() : commands[i]->getName())==args->operator [](0)){
|
||
|
return (launchThread ? threadCommands[i]->execute(args, parent) : commands[i]->execute(args, parent));
|
||
|
}
|
||
|
}
|
||
|
throw CommandNotFoundException();
|
||
|
}
|
||
|
|
||
|
|