so this was all done in #evi and compiled with g++
here's the actual code:
/*
basic timer script by beaiouns
written in 2026
this software is unlicensed, use it or don't, tell your friends if you like
just temper your expectations
Usage: peels (seconds)
Example: "peels 10" to peels for 10 seconds.
*/
#include <iostream> // used for basic shit
#include <chrono> // used to tell time (1s)
#include <thread> // used to sleep thread based on the chrono thingy
using namespace std; // i don't wanna type std:: a lot
// this block prints out what we're expecting to happen
// call it when something unexpected happens
void wtfBox() {
cout << "\nUsage: peels (seconds)\n";
cout << "Example: \"peels 10\" to peels for 10 seconds.\n\n";
}
//the main bit
int main(int argc, char* argv[]) {
if (argc != 2) {
wtfBox(); // if they didn't do it right, give them the instructions
} else {
int timeLeft = atoi(argv[1]); // this converts the 2nd argument into a number, e.g. 10
if (timeLeft == 0) {
wtfBox(); // if they didn't do it right, give them the instructions
return 0; // and then don't run the whole loop
}
while (timeLeft > 0) { // here's where the timer actually starts
string sendOut = "Time left: " + to_string(timeLeft); // string to send
// first we gotta blank out the line before printing any new ones
int spacesToPrint = sendOut.length(); // length of what we printed last
int printSpace = 0;
cout << "\r"; // go to the start of the line
while (printSpace <= spacesToPrint) {
cout << " ";
printSpace++;
} // print a bunch of spaces
cout << "\r"; // back to start
cout << sendOut << flush; // here's where we print the current time left
this_thread::sleep_for(1s); // now we wait 1 second
timeLeft--; // and now we have 1 less second to wait
}
// now we're done, so print how long we waited
// the last thing we printed was "Time left: 1" so i'm just gonna print that many spaces
cout << "\r \rYou waited " << argv[1] << " seconds.\n";
}
//end
return 0;
}