Skip to content

Commit 9d89226

Browse files
author
benja2998
committed
code: a lot more documentation
1 parent 76b4966 commit 9d89226

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ std::string checked6 = "[ ]";
4545
void initialize();
4646

4747
void banner() {
48+
/* Using raw string literals for multiline strings. */
4849
const char* banner = R"(
4950
.__ __ .__ __ .__
5051
_____ __ __| |_/ |_|__|/ |_ ____ ____ | | .__ .__ )";
@@ -57,6 +58,7 @@ void banner() {
5758
|__|_| /____/|____/__| |__||__| \____/ \____/|____/ |__| |__|
5859
\/ )";
5960

61+
/* Print using ansi color codes for a fade effect from white to blue. */
6062
std::cout << ansi::BG_BLACK;
6163
std::cout << ansi::BOLD << ansi::WHITE << banner << ansi::RESET;
6264
std::cout << ansi::BG_BLACK;
@@ -180,8 +182,10 @@ void menu() {
180182

181183
void read() {
182184
char check = char_utils::get_char();
185+
/* Removed this line below since it looks bad. */
183186
//std::cout << ansi::CYAN << "Validating choice... " << ansi::RESET;
184187

188+
/* This is the least efficient way to do it, but i don't want to use things like ncurses. */
185189
if (check == 'w' || check == 'W') {
186190
if (checked2 == "[x]") {
187191
checked2 = "[ ]";
@@ -248,7 +252,9 @@ void read() {
248252
std::cout << ansi::GREEN << "Valid choice!" << ansi::RESET << "\n";
249253
std::cout << ansi::BOLD << ansi::ITALIC << ansi::CYAN << "Welcome to the calculator shell, type 'help' for commands.\n" << ansi::RESET;
250254
option_shell();
251-
initialize();
255+
initialize(); /* Workaround for not being able to call initialize() in the header file.
256+
* Since option_shell() runs in the same thread, initialize() will only run after the user exits the calculator shell.
257+
*/
252258
}
253259
}
254260
else {
@@ -258,6 +264,8 @@ void read() {
258264
}
259265
}
260266

267+
/* Probably the most useful function in the program. */
268+
/* Helps a lot for returning to the main menu. */
261269
void initialize() {
262270
console::clear();
263271
menu();
@@ -268,6 +276,7 @@ void checkCurlIsInstalled() {
268276
#ifdef _WIN32
269277
int curl = system("curl --version >nul 2>&1");
270278
if (curl != 0) {
279+
/* Either the user is not intelligent life and removed curl.exe or they are running an old version of Windows. */
271280
std::cout << "Curl not installed. Install it by running: winget install cURL.cURL\n";
272281
exit(1);
273282
}

0 commit comments

Comments
 (0)