diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..2bbcd146395829e97414aa324603e59f83effd8f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "vector": "cpp" + } +} \ No newline at end of file diff --git a/README.md b/README.md index 1965b43b68601eb23632bf284a6f11a7f39cc429..d1066b2eb34b99aa918cc9c087f0f68183b2cced 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Nosh is a simple, customizable command-line shell designed for Windows systems. `about --version`: Display the version of the shell. +`exec`: Execute executable files. + `exit`: Exit the shell program. `grasp`: Search through directories for files or directories. Supports: @@ -19,17 +21,17 @@ Nosh is a simple, customizable command-line shell designed for Windows systems. `list`: Display the contents of a directory or the current working directory. -`mkdir`: Create a new directory. Usage: `mkdir <directory_name>` +`mkdir`: Create a new directory. Usage: `mkdir <directory_name>`. -`noemi`: Draw a heart shape made of # characters +`noemi`: Draw a heart shape made of # characters. -`noemi -l`: Draw a heart shape made of # characters with more delay +`noemi -l`: Draw a heart shape made of # characters with more delay. | -`rn (rename)`: Rename a file or directory. Usage: `rn <old_name> <new_name>` - -`store`: Save content to a specified file. This could be used to store commands or data for later use. +`rn (rename)`: Rename a file or directory. Usage: `rn <old_name> <new_name>`. +`store`: Save a string of maximum 100 characters during runtime. +`store -g`: Show the string saved with `store`. ## Installation diff --git a/nosh.cpp b/nosh.cpp index 8995ce3a5cc833637028d734ccc90ca4b63870b6..33dede3dfc720b222aa46e10e21d5266fa2dfe34 100644 --- a/nosh.cpp +++ b/nosh.cpp @@ -35,8 +35,9 @@ #include <fstream> // Reading/Creating files #include <cstring> // String operations #include <regex> // For grasp filtering +#include <cstdlib> -#define VERSION 0.3 //< Change version number here for the entire code +const char VERSION[] = "0.3.1"; //< Change version number here for the entire code #define STRLEN 100 //< Max string length char vault[STRLEN]; //< Storing custom info; @@ -59,7 +60,8 @@ void handle_tap(const vector<string>& args); void handle_crush(const vector<string>& args); void handle_mkdir(const vector<string>& args); void handle_rn(const vector<string>& args); - +void handle_snatch(const vector<string>& args); +void handle_exec(const vector<string>& args); /** * The main code @@ -127,11 +129,23 @@ int main() { return 0; // Terminate program with success } + /** - * Function for handling the pwd command - * - * @param args for the arguments + * Runs executable files using the 'system' function + * + * @param args for arguments */ +void handle_exec(const vector<string>& args){ + if (args.size() != 2){ + cout << "Usage: exec <file_to_execute>\n"; + return; // Exit early + } + + string path = args[1]; + + system(path.c_str()); // Runs the executable +} + /** * Handling the 'pwd' command for printing the working directory @@ -213,6 +227,11 @@ bool is_builtin_command(const vector<string>& args){ return true; } + if (args[0] == "exec"){ + handle_exec(args); + return true; + } + if (args[0] == "list") { handle_list(args); return true; @@ -433,7 +452,7 @@ void handle_storage(const vector<string>& args) { cout << "Enter text to store in memory (MAX 100 characters): "; cin.getline(vault, STRLEN); // Use getline to capture input cout << "Storing: \"" << vault << "\" in memory.\n"; - } else if (args.size() == 2 && args[1] == "get") { + } else if (args.size() == 2 && args[1] == "-g") { // Retrieve stored text if (strlen(vault) == 0) { cout << "No text stored in memory.\n"; diff --git a/nosh.exe b/nosh.exe new file mode 100644 index 0000000000000000000000000000000000000000..2d6d6faf550f789f42aa2e9718416a90f1b8fba8 Binary files /dev/null and b/nosh.exe differ