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

Added new command

parent d7021c76
No related branches found
No related tags found
No related merge requests found
{
"files.associations": {
"vector": "cpp",
"deque": "cpp"
"deque": "cpp",
"iostream": "cpp"
}
}
\ No newline at end of file
......@@ -30,7 +30,9 @@ Nosh is a simple, customizable command-line shell designed for Windows systems.
`noemi`: Draw a heart shape made of # characters.
`noemi -l`: Draw a heart shape made of # characters with more delay.
|
`now`: Gets and prints out the current date and tame.
`rn (rename)`: Rename a file or directory. Usage: `rn <old_name> <new_name>`.
`store`: Save a string of maximum 100 characters during runtime.
......@@ -72,7 +74,7 @@ Before contributing, please note that if you create a derivative or customized v
````
MIT License
Copyright (c) 2025 Zsombor Szabó-Antalovszky
Copyright (C) 2025 Zsombor Szabó-Antalovszky
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, subject to the following conditions:
......
/**
* Copyright (c) 2025 Zsombor Szabó-Antalovszky
* Copyright (C) 2025 Zsombor Szabó-Antalovszky
*
* -------------------------------------------------------------------------------------------------------------------
* Dear future programmer,
......@@ -29,11 +29,9 @@
*
* CHANGELOG
*
* Noémi Shell v.0.4
* Noémi Shell ver. 0.3.3
*
* 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.
* This version introduces the new 'now' command that prints out the current date and time.
*
*/
......@@ -49,7 +47,8 @@
#include <cstdlib>
#include <deque>
const char VERSION[] = "0.3.2"; ///< Change version number here for the entire code
const char VERSION[] = "0.3.3"; ///< Change version number here for the entire code
#define STRLEN 100 ///< Max string length
#define WIDTH 10 ///< Width between columns
......@@ -73,14 +72,15 @@ void handle_crush(const vector<string>& args);
void handle_mkdir(const vector<string>& args);
void handle_rn(const vector<string>& args);
void handle_exec(const vector<string>& args);
void handle_help(const vector<string>& args);
void handle_now(const vector<string>& args);
/**
* The main function
*/
int main() {
cout << "Noemi Shell (nosh)\n"
cout << "Noemi Shell (nosh) ver. " << VERSION << "\n"
<< "Copyright (C) 2025 Zsombor Szabo-Antalovszky\n\n"
<< "Type 'help' or '? for list of available commands\n\n";
......@@ -160,6 +160,7 @@ void handle_help(const vector<string>& args){
<< "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"
<< "now: Gets and prints out the curent date and time\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";
......@@ -181,6 +182,29 @@ void handle_exec(const vector<string>& args){
system(path.c_str()); // Runs the executable
}
/**
* Gets and prints out the current date
*
* @param args for arguments
*/
void handle_now(const vector<string>& args){
// If arguments exist
if (args.size() > 2){
cout << "now: too many arguments\n";
return;
}
// Set timestamp
time_t timestamp;
time(&timestamp);
// Print out date and time
cout << "\n" << ctime(&timestamp) << "\n";
}
/**
* Handling the 'pwd' command for printing the working directory
*
......@@ -224,7 +248,7 @@ bool is_builtin_command(const vector<string>& args){
if (args.size() == 2) {
if (args[1] == "--version"){
cout << "v" << VERSION;
cout << "ver. " << VERSION;
cout << "\n";
return true;
}
......@@ -234,9 +258,10 @@ bool is_builtin_command(const vector<string>& args){
}
}
cout << "\nNoemi Shell v" << VERSION;
cout << "\n";
cout << "Copyright (C) 2025 Zsombor Szabo-Antalovszky \n" << endl;
cout << "\nNoemi Shell (nosh) ver. " << VERSION << "\n"
<< "Copyright (C) 2025 Zsombor Szabo-Antalovszky\n\n"
<< "Type 'help' or '? for list of available commands\n\n";
return true;
}
......@@ -326,6 +351,11 @@ bool is_builtin_command(const vector<string>& args){
return true;
}
if (args[0] == "now"){
handle_now(args);
return true;
}
return false; // Return false if given command does not exist
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment