From 36cfe14015df8546829476a77a843f45a4087cf2 Mon Sep 17 00:00:00 2001 From: DRAGONTOS Date: Mon, 21 Oct 2024 23:56:50 +0200 Subject: [PATCH] fix: fixed formatting and made time out work --- line-count | 6 +++--- src/Regex.cpp | 4 ++-- src/includes/Regex.hpp | 10 +++++++--- src/maincommand.cpp | 35 ++++++++++------------------------- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/line-count b/line-count index 8649f46..f0976f7 100644 --- a/line-count +++ b/line-count @@ -1,8 +1,8 @@ =============================================================================== Language Files Lines Code Comments Blanks =============================================================================== - C++ 4 383 308 26 49 - C++ Header 4 67 56 1 10 + C++ 4 368 293 26 49 + C++ Header 4 71 56 6 9 =============================================================================== - Total 8 450 364 27 59 + Total 8 439 349 32 58 =============================================================================== diff --git a/src/Regex.cpp b/src/Regex.cpp index e0a447a..1fa886c 100644 --- a/src/Regex.cpp +++ b/src/Regex.cpp @@ -67,7 +67,7 @@ void slashing(cmd *inputCmd) { // Count the number of lines while (std::getline(inputStream, line)) { - inputCmd->step++; + inputCmd->slashtp++; } - inputCmd->slash = (inputCmd->step == 2) ? R"( )": R"( \ )"; + inputCmd->slash = (inputCmd->slashtp == 2) ? R"( )": R"( \ )"; } diff --git a/src/includes/Regex.hpp b/src/includes/Regex.hpp index 47b9110..b209ed4 100644 --- a/src/includes/Regex.hpp +++ b/src/includes/Regex.hpp @@ -4,14 +4,16 @@ // all the var's struct cmd { +// legacy const char *userHome = getenv("HOME"); - std::string usercache = std::string(userHome) + "/.cache/"; std::string cacheid = std::string(usercache) + "ids.txt"; std::string cachesc = std::string(usercache) + "sources.html"; +// unsure std::string ids; +// what the args need std::string collectionid; std::string modid; std::string user = "anonymous"; @@ -19,11 +21,13 @@ std::string pass; std::string gameid; std::string dir; -int ab = 0; -int step = 0; +int ab = 0; +// slashing +int slashtp = 0; std::string slash; +// counter int successes = 0; int timedout = 0; int errors = 0; diff --git a/src/maincommand.cpp b/src/maincommand.cpp index f3b6a2f..a8bf8e5 100644 --- a/src/maincommand.cpp +++ b/src/maincommand.cpp @@ -1,22 +1,5 @@ -#include #include -#include -#include -#include "includes/Regex.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include #include #include #include @@ -40,7 +23,7 @@ void execAndDisplay(cmd *inputCmd, const std::string& cmd, std::atomic& ru } // checks for timed out ones. - if (line.find("Time") != std::string::npos) { + if (line.find("Timeout") != std::string::npos) { inputCmd->timedout++; } @@ -90,13 +73,15 @@ void maincommand(cmd *inputCmd) { std::cerr << "\nError: " << e.what() << std::endl; } - // 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" - + "Finished: " + std::to_string(inputCmd->successes +1) + "\n" - + "Timed out: " + std::to_string(inputCmd->timedout) + "\n" - + "Errored: " + std::to_string(inputCmd->errors) + "\n" + "\n"; - + // 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 + std::string mods = total + "\n" + + "Finished: " + std::to_string(inputCmd->successes +1) + "\n" + + "Timed out: " + std::to_string(inputCmd->timedout) + "\n" + + "Errored: " + std::to_string(inputCmd->errors) + "\n" + "\n"; + std::cout << "\n\n" + mods + colm + " has been downloaded too: " + inputCmd->dir + "\n"; }