Skip to content

Instantly share code, notes, and snippets.

@Glamhoth
Created December 4, 2016 22:40
Show Gist options
  • Save Glamhoth/597bf49bc2e641fb342298239ac55dd4 to your computer and use it in GitHub Desktop.
Save Glamhoth/597bf49bc2e641fb342298239ac55dd4 to your computer and use it in GitHub Desktop.
#ifndef COMMANDS_H_INCLUDED
#define COMMANDS_H_INCLUDED
void mainDir(std::string);
void makeReady();
void welcomeLogin();
std::string currLoc ("home");
std::string prevLoc ("");
void commandExecute(std::string command)
{
if (command == "exit")
{
std::cout << "TURNING OFF..." << std::endl;
exit(0);
}
else if (command == "logout")
{
system("CLS");
currLoc = "home";
prevLoc = "";
welcomeLogin();
}
else if (command == "dir")
{
mainDir(currLoc);
}
else if (command == "cd:A")
{
if (currLoc == "home")
{
prevLoc = "home";
currLoc = ("A:");
makeReady();
}
else
{
std::cout << "Directory doesn't exist." << std::endl;
makeReady();
}
}
else if (command == "cd")
{
currLoc = ("home");
makeReady();
}
else if (command == "cd:")
{
if (prevLoc == "home")
{
currLoc = ("home");
makeReady();
}
else
{
commandExecute(prevLoc);
}
}
else
{
std::cout << "Wrong command." << std::endl;
makeReady();
}
}
#endif // COMMANDS_H_INCLUDED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment