bumped: (0.1.5) moved slashing to regex.cpp

This commit is contained in:
Kaley, Fischer 2024-10-19 17:04:24 +02:00
parent 1171c40e7e
commit 3079cb8422
5 changed files with 24 additions and 18 deletions

View file

@ -1,6 +1,6 @@
pkgname=stc-git pkgname=stc-git
_gitname=stc _gitname=stc
pkgver=0.1.4 pkgver=0.1.5
pkgrel=1 pkgrel=1
pkgdesc="Easily download collections and mods from steam." pkgdesc="Easily download collections and mods from steam."
url="https://github.com/DRAGONTOS/stc" url="https://github.com/DRAGONTOS/stc"

View file

@ -1,3 +1,3 @@
{ {
"version": "0.1.4" "version": "0.1.5"
} }

View file

@ -63,3 +63,15 @@ void Regex(cmd *inputCmd) {
outputFile.close(); outputFile.close();
} }
} }
void slashing(cmd *inputCmd) {
//checks if a "\" is needed or not
std::ifstream idscount{inputCmd->cacheid};
for (std::string line; std::getline(idscount, line); ) {
inputCmd->step++;
}
inputCmd->slash = (inputCmd->step == 2) ? R"( )": R"( \ )";
idscount.close();
}

View file

@ -2,6 +2,7 @@
#define REGEX_H #define REGEX_H
#include <string> #include <string>
// all the var's
struct cmd { struct cmd {
const char *userHome = getenv("HOME"); const char *userHome = getenv("HOME");
@ -17,8 +18,12 @@ std::string gameid;
std::string dir; std::string dir;
int ab = 0; int ab = 0;
int step = 0;
std::string slash;
}; };
// void Regex(const std::string& collectionid, const std::string& gameid, const std::string& cacheid, const std::string& cachesc); // void Regex(const std::string& collectionid, const std::string& gameid, const std::string& cacheid, const std::string& cachesc);
void Regex(cmd *inputCmd); void Regex(cmd *inputCmd);
void slashing(cmd *inputCmd);
#endif #endif

View file

@ -19,11 +19,10 @@ std::string woof(std::ifstream &meow) {
} }
int main(int argc, char **argv, char **envp) { int main(int argc, char **argv, char **envp) {
// struct cmd // struct cmd
cmd inputCmd; cmd inputCmd;
inputCmd.dir = std::filesystem::current_path();
inputCmd.dir = std::filesystem::current_path();
// Removes cache // Removes cache
if (std::filesystem::exists(inputCmd.cacheid) && if (std::filesystem::exists(inputCmd.cacheid) &&
std::filesystem::is_directory(inputCmd.cacheid)) { std::filesystem::is_directory(inputCmd.cacheid)) {
@ -164,27 +163,17 @@ int main(int argc, char **argv, char **envp) {
// regex function // regex function
Regex(&inputCmd); Regex(&inputCmd);
slashing(&inputCmd);
//checks if a "\" is needed or not
std::ifstream idscount{inputCmd.cacheid};
int step = 0;
for (std::string line; std::getline(idscount, line); ) {
step++;
}
std::string slash = (step == 2) ? R"( )": R"( \ )";
idscount.close();
//gets the ids //gets the ids
std::ifstream ids{inputCmd.cacheid}; std::ifstream ids{inputCmd.cacheid};
std::string idsm = (inputCmd.ab == 1) ? R"( +workshop_download_item )" + inputCmd.gameid + " " + inputCmd.modid + " +quit": R"()"; std::string idsm = (inputCmd.ab == 1) ? R"( +workshop_download_item )" + inputCmd.gameid + " " + inputCmd.modid + " +quit": R"()";
// main command // main command
system(std::string{"sh ~/Steam/steamcmd.sh +force_install_dir " + inputCmd.dir + " +login " + inputCmd.user + inputCmd.pass + slash + idsm + woof(ids)}.c_str()); system(std::string{"sh ~/Steam/steamcmd.sh +force_install_dir " + inputCmd.dir + " +login " + inputCmd.user + inputCmd.pass + inputCmd.slash + idsm + woof(ids)}.c_str());
// shows how much and what has downloaded // shows how much and what has downloaded
std::string mods = (!inputCmd.modid.empty()) ? "" : R"(Mods: )" + std::to_string(step -1) + "\n"; std::string mods = (!inputCmd.modid.empty()) ? "" : R"(Mods: )" + std::to_string(inputCmd.step -1) + "\n";
std::string colm = (inputCmd.ab == 1) ? R"(Mod)": R"(Collection)"; 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";