Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake used #25

Merged
merged 1 commit into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified lib/libcpr.so.1.5.0
Binary file not shown.
Binary file modified lib/libcurl.so
Binary file not shown.
Binary file modified lib/libgmock.so
Binary file not shown.
Binary file modified lib/libgmock_main.so
Binary file not shown.
Binary file modified lib/libgtest.so
Binary file not shown.
Binary file modified lib/libgtest_main.so
Binary file not shown.
Binary file modified lib/libmongoose.a
Binary file not shown.
84 changes: 82 additions & 2 deletions src/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "../include/launch.hpp"
#include "../include/levels.hpp"
#include "../include/tutorial.hpp"
#include <../include/color.hpp>
#include <fstream>
#include <iomanip>

using namespace std;

Expand Down Expand Up @@ -110,8 +113,85 @@ int roosh_exec_tutorial(char **args, int num_args)
}
}

void printcommand(string line, int width)
{
const char separator = ' ';
cout << " " << left << setw(width) << setfill(separator) << line;
}
void write_tutorial(string filepath)
{
string line;

ifstream myfile(filepath);

if (myfile.is_open())
{
while (getline(myfile, line))
{
string cmd_path = home_dir + "/tutorial/tutorial_cmd/" + line + ".txt";
ifstream filename(cmd_path);
cout << MAGENTA;
printcommand(line, 60);
cout << RESET;
getline(myfile, line);
printcommand(line, 88);
cout << endl;
cout << endl;
string cmd;

if (filename.is_open())
{

while (getline(filename, cmd))
{
cout << CYAN;
printcommand(cmd, 60);
getline(filename, cmd);
cout << RESET;
printcommand(cmd, 88);
cout << endl;
cout << endl;
}

filename.close();
}
int n = 50;
while (n--)
cout << "-";
cout << endl;
cout << endl;
}
myfile.close();
}

else
cout << "Unable to open file";
}

int roosh_tutorial()
{
cout << "My tutorial :)\n";
cout << "\n"
<< BLUE << " "
<< "Basic linux commands" << endl;
cout << RESET << endl;
write_tutorial(home_dir + "/tutorial/tutorial_cmd/basiccmdlist.txt");
cout << BLUE << " "
<< "Intermediate linux commands" << endl;
cout << RESET << endl;
write_tutorial(home_dir + "/tutorial/tutorial_cmd/intermediatecmdlist");
cout << MAGENTA << "pipes (|)" << RESET << " "
<< "to pass output of one command as intput to another" << endl;
cout << endl;
cout << MAGENTA << "Redirection" << RESET << endl;
cout << endl;
cout << "1.output redirection(<)"
<< " "
<< " to fetch output to a file" << endl;
cout << endl;
cout << "2.Input redirection(>)"
<< " "
<< " to take input from a file" << endl;
cout << endl;

return 1;
}
}