Skip to content
Snippets Groups Projects
Commit 83e2bfb6 authored by My Name's avatar My Name
Browse files

Added new command and updated readme

parent aea802c6
Branches
Tags
No related merge requests found
{
"files.associations": {
"vector": "cpp"
}
}
\ No newline at end of file
......@@ -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
......
......@@ -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";
......
nosh.exe 0 → 100644
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment