diff --git a/src/main.cpp b/src/main.cpp index eed26f4..d3155df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,12 +56,14 @@ int main(int argc, char **argv, char **envp) { std::string cachesc = std::string(userCache) + "sources.html"; std::string collectionid; + std::string modid; std::string user = "anonymous"; std::string pass; std::string gameid; std::string dir; dir = std::filesystem::current_path(); + // Removes cache if (std::filesystem::exists(cacheid) && std::filesystem::is_directory(cacheid)) { int status = remove(std::string {cacheid}.c_str()); @@ -83,63 +85,105 @@ int main(int argc, char **argv, char **envp) { // the args for (int i = 1; i < argc; ++i) { - std::string arg = argv[i]; + std::string arg = argv[i]; + if (ARGS[i] == "-ci") { // collection id - collectionid = ARGS[1+1]; - std::cout << collectionid; - // should be done with libcurl in the future ata - system(std::string {"curl https://steamcommunity.com/sharedfiles/filedetails/?id=" + collectionid + " -o " + cachesc}.c_str()); - - if (ARGS[i+2] == "-u") { // user if required [OPTIONAL] - user = ARGS[i+3]; - std::cout << user; - } else if (ARGS[i+2] == "-gi") { // game id - gameid = ARGS[i+3]; - std::cout << gameid; - if (ARGS[i+4] == "-d") { - dir = ARGS[i+5]; - std::cout << dir; - } - break; - } + collectionid = ARGS[1+1]; + std::cout << collectionid; + // should be done with libcurl in the future ata + system(std::string {"curl https://steamcommunity.com/sharedfiles/filedetails/?id=" + collectionid + " -o " + cachesc}.c_str()); + } else if (ARGS[i] == "-mi") { + modid = ARGS[1+1]; + std::cout << modid; + } - if (ARGS[i+4] == "-p") { // pass [OPTIONAL] - pass = ARGS[i+5]; - std::cout << pass; - } - - if (ARGS[i+6] == "-gi") { // game id - gameid = ARGS[i+7]; - std::cout << gameid; - } - - if (ARGS[i+8] == "-d") { // download dir [OPTIONAL] - dir = ARGS[i+9]; + if (ARGS[i+2] == "-u") { // user if required [OPTIONAL] + user = ARGS[i+3]; + std::cout << user; + } else if (ARGS[i+2] == "-gi") { // game id + gameid = ARGS[i+3]; + std::cout << gameid; + if (ARGS[i+4] == "-d") { + dir = ARGS[i+5]; std::cout << dir; } - + break; } + + if (ARGS[i+4] == "-p") { // pass [OPTIONAL] + pass = ARGS[i+5]; + std::cout << pass; + } + + if (ARGS[i+6] == "-gi") { // game id + gameid = ARGS[i+7]; + std::cout << gameid; + } + + if (ARGS[i+8] == "-d") { // download dir [OPTIONAL] + dir = ARGS[i+9]; + std::cout << dir; + } + + } - // Not Working idk why hope someone can help with regex - // std::ifstream file(cachesc); - // std::ofstream outputFile(cacheid); - // - // if (file.is_open() && outputFile.is_open()) { - // std::string line; - // while (std::getline(file, line)) { - // std::regex pattern(R"(