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

Added help command

parent 83e2bfb6
No related branches found
No related tags found
No related merge requests found
{
"files.associations": {
"vector": "cpp"
"vector": "cpp",
"deque": "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.
`clear` or `cls`: Display the version of the shell.
`exec`: Execute executable files.
`exit`: Exit the shell program.
......@@ -19,6 +21,8 @@ Nosh is a simple, customizable command-line shell designed for Windows systems.
`grasp -f <directory>`: (In development) Specify a file to search for, to be implemented with the pattern matching feature.
`help` or `?`: Lists all available commands for Noémi Shell.
`list`: Display the contents of a directory or the current working directory.
`mkdir`: Create a new directory. Usage: `mkdir <directory_name>`.
......
......@@ -24,6 +24,17 @@
* @author ChatGPT (a lot of help)
*
* Licensed under a modified MIT License. See the license on the Noémi Shell GitLab repo for details.
*
* --------------------------------------------------------------------------------------------------------------------
*
* CHANGELOG
*
* Noémi Shell v.0.4
*
* This version introduces the 'exec' command for executing executable files.
* Exec is using the system command via the Windows API. This version also changed the 'store get'
* command to 'store -g' for improved standardization.
*
*/
......@@ -36,18 +47,24 @@
#include <cstring> // String operations
#include <regex> // For grasp filtering
#include <cstdlib>
#include <deque>
const char VERSION[] = "0.3.1"; //< Change version number here for the entire code
#define STRLEN 100 //< Max string length
const char VERSION[] = "0.3.2"; ///< Change version number here for the entire code
#define STRLEN 100 ///< Max string length
#define WIDTH 10 ///< Width between columns
char vault[STRLEN]; //< Storing custom info;
char vault[STRLEN]; ///< Storing custom info;
deque<std::string> commandHistory;
const int MAXHISTORY = 50;
int numberOfHistories = 0; ///< Storing the number of histories
namespace fs = std::filesystem;
using namespace std;
// Declaring functions
void handle_pwd(const vector<string>& args);
bool is_builtin_command(const vector<string>& args);
void handle_noemi(const vector<string>& args);
......@@ -60,17 +77,18 @@ 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
* The main function
*/
int main() {
cout << "Noemi Shell (nosh)\n";
cout << "Copyright (C) 2025 Zsombor Szabo-Antalovszky\n\n";
cout << "Noemi Shell (nosh)\n"
<< "Copyright (C) 2025 Zsombor Szabo-Antalovszky\n\n"
<< "Type 'help' or '? for list of available commands\n\n";
string command; // Storing command
......@@ -115,7 +133,7 @@ int main() {
continue;
}
// Example: Handling unrecognized commands
// Handling unrecognized commands
if (!is_builtin_command(args)) {
cout << "Unrecognized command: ";
for (const auto& arg : args) {
......@@ -129,6 +147,28 @@ int main() {
return 0; // Terminate program with success
}
void handle_help(const vector<string>& args){
if (args.size() < 1){
cout << "help: too many arguments\n";
return; // Exit early
}
cout << "about: Displays shell information\n"
<< "about --version: Displays shell version only\n"
<< "exec: Execute an executable file\n"
<< "exit: Exit the shell\n"
<< "grasp -d: Search through directories for other directories\n"
<< "grasp -f: Search through directories for files\n"
<< "list: List the files or other directories whithin a directory\n"
<< "mkdir: Create a new directory whithin current directory\n"
<< "noemi: Draw a heart shape made of # characters\n"
<< "noemi -l: Draw a heart shape made of # characters with more delay\n"
<< "rn: rename a file or a directory\n"
<< "store: Save a string of maximum 100 characters during runtime\n"
<< "store -g: Show the string saved with store\n\n";
}
/**
* Runs executable files using the 'system' function
......@@ -146,7 +186,6 @@ void handle_exec(const vector<string>& args){
system(path.c_str()); // Runs the executable
}
/**
* Handling the 'pwd' command for printing the working directory
*
......@@ -216,6 +255,26 @@ bool is_builtin_command(const vector<string>& args){
return true;
}
if (args[0] == "cls"){
if (args.size() > 1) {
cout << "clear: too many arguments";
return true;
}
system("cls");
return true;
}
if (args[0] == "help"){
handle_help(args);
return true;
}
if (args[0] == "?"){
handle_help(args);
return true;
}
if (args[0] == "noemi"){
handle_noemi(args);
......@@ -286,7 +345,7 @@ bool is_builtin_command(const vector<string>& args){
void handle_noemi(const vector<string>& args){
if (args.size() > 2){
cout << "Usage: noemi <delay argument> ";
cout << "Usage: noemi <optional_delay_argument>\n";
return; // Exit early
}
......@@ -296,17 +355,18 @@ void handle_noemi(const vector<string>& args){
if (args.size() == 2){
const string option = args[1]; // Set the option variable to the first argument
if (option == "-l") time = 500; // 500 milliseconds between each line
if (option == "-l"){
time = 500; // 500 milliseconds between each line
}
else{
cout << "noemi: unrecognized argument " << args[1] << "\n";
return; // Exit early;
}
}
cout << " \n\t ####### #######\n";
cout << " \n\t ######### ########\n";
Sleep(time);
cout << " ########### ###########\n";
cout << " ############ ###########\n";
Sleep(time);
cout << " ############### ###############\n";
Sleep(time);
......@@ -405,6 +465,8 @@ void handle_cd(const vector<string>& args) {
cout << "cd: " << new_path << ": No such directory\n";
}
}
}
/**
......
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment