Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # MAKE SURE TO ADD IN THE UP OF THE FILE
- #include "../include/GlobalVariables.h"
- //# History implementation
- // Constructor
- HistoryCommand::HistoryCommand(string args, const vector<BaseCommand *> & history)
- :BaseCommand(args), history(history){}
- void HistoryCommand::execute(FileSystem & fs){
- for(int i=0;i<history.size();i++)
- cout << i << "\t" << history.at(i)->toString() << endl;
- }
- string HistoryCommand::toString(){
- cout << "history" << endl;
- }
- //# ExecCommand implementation
- // Constructor
- ExecCommand::ExecCommand(string args, const vector<BaseCommand *> & history)
- :BaseCommand(args), history(history){}
- void ExecCommand::execute(FileSystem & fs){
- int index = stoi(getArgs()); // get int from string
- if(index < history.size()){ // TODO: make sure it works for history.size input(and alike)
- history.at(index)->execute(fs);
- } else{ cout << "Command not found" << endl; }
- }
- string ExecCommand::toString(){
- cout << "exec" << endl;
- }
- //# Verbose Command implementation
- VerboseCommand::VerboseCommand(string args): BaseCommand(args){}
- void VerboseCommand::execute(FileSystem & fs){
- unsigned int val = stoi(getArgs()); // get int from string
- if(val <= 3 && val >= 0) {
- verbose = val;
- }else{ cout << "Wrong verbose input" << endl;}
- }
- string VerboseCommand::toString(){
- cout << "verbose" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement