fix: fixed formatting and made time out work

This commit is contained in:
Kaley, Fischer 2024-10-21 23:56:50 +02:00
parent 1bb8e7ee49
commit 36cfe14015
4 changed files with 22 additions and 33 deletions

View file

@ -1,8 +1,8 @@
=============================================================================== ===============================================================================
Language Files Lines Code Comments Blanks Language Files Lines Code Comments Blanks
=============================================================================== ===============================================================================
C++ 4 383 308 26 49 C++ 4 368 293 26 49
C++ Header 4 67 56 1 10 C++ Header 4 71 56 6 9
=============================================================================== ===============================================================================
Total 8 450 364 27 59 Total 8 439 349 32 58
=============================================================================== ===============================================================================

View file

@ -67,7 +67,7 @@ void slashing(cmd *inputCmd) {
// Count the number of lines // Count the number of lines
while (std::getline(inputStream, line)) { while (std::getline(inputStream, line)) {
inputCmd->step++; inputCmd->slashtp++;
} }
inputCmd->slash = (inputCmd->step == 2) ? R"( )": R"( \ )"; inputCmd->slash = (inputCmd->slashtp == 2) ? R"( )": R"( \ )";
} }

View file

@ -4,14 +4,16 @@
// all the var's // all the var's
struct cmd { struct cmd {
// legacy
const char *userHome = getenv("HOME"); const char *userHome = getenv("HOME");
std::string usercache = std::string(userHome) + "/.cache/"; std::string usercache = std::string(userHome) + "/.cache/";
std::string cacheid = std::string(usercache) + "ids.txt"; std::string cacheid = std::string(usercache) + "ids.txt";
std::string cachesc = std::string(usercache) + "sources.html"; std::string cachesc = std::string(usercache) + "sources.html";
// unsure
std::string ids; std::string ids;
// what the args need
std::string collectionid; std::string collectionid;
std::string modid; std::string modid;
std::string user = "anonymous"; std::string user = "anonymous";
@ -20,10 +22,12 @@ std::string gameid;
std::string dir; std::string dir;
int ab = 0; int ab = 0;
int step = 0;
// slashing
int slashtp = 0;
std::string slash; std::string slash;
// counter
int successes = 0; int successes = 0;
int timedout = 0; int timedout = 0;
int errors = 0; int errors = 0;

View file

@ -1,22 +1,5 @@
#include <atomic>
#include <iostream> #include <iostream>
#include <string>
#include <thread>
#include "includes/Regex.hpp"
#include <cctype>
#include <cpptoml.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <ostream>
#include <string>
#include <iostream>
#include <cstdio>
#include <memory>
#include <stdexcept> #include <stdexcept>
#include <string>
#include <unistd.h>
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include <atomic> #include <atomic>
@ -40,7 +23,7 @@ void execAndDisplay(cmd *inputCmd, const std::string& cmd, std::atomic<bool>& ru
} }
// checks for timed out ones. // checks for timed out ones.
if (line.find("Time") != std::string::npos) { if (line.find("Timeout") != std::string::npos) {
inputCmd->timedout++; inputCmd->timedout++;
} }
@ -90,13 +73,15 @@ void maincommand(cmd *inputCmd) {
std::cerr << "\nError: " << e.what() << std::endl; std::cerr << "\nError: " << e.what() << std::endl;
} }
// mod or collection?
std::string total = (!inputCmd->modid.empty()) ? "Total: 1" : "Total: " + std::to_string(inputCmd->slashtp -1) + "\n";
std::string colm = (inputCmd->ab == 1) ? R"(Mod)": R"(Collection)";
// shows how much and what has downloaded // shows how much and what has downloaded
std::string total = (!inputCmd->modid.empty()) ? "Total: 1" : "Total: " + std::to_string(inputCmd->step -1) + "\n";
std::string mods = total + "\n" std::string mods = total + "\n"
+ "Finished: " + std::to_string(inputCmd->successes +1) + "\n" + "Finished: " + std::to_string(inputCmd->successes +1) + "\n"
+ "Timed out: " + std::to_string(inputCmd->timedout) + "\n" + "Timed out: " + std::to_string(inputCmd->timedout) + "\n"
+ "Errored: " + std::to_string(inputCmd->errors) + "\n" + "\n"; + "Errored: " + std::to_string(inputCmd->errors) + "\n" + "\n";
std::string colm = (inputCmd->ab == 1) ? R"(Mod)": R"(Collection)";
std::cout << "\n\n" + mods + colm + " has been downloaded too: " + inputCmd->dir + "\n"; std::cout << "\n\n" + mods + colm + " has been downloaded too: " + inputCmd->dir + "\n";
} }