diff --git a/include/config.h b/include/config.h index 54f1c9f..f37a90e 100644 --- a/include/config.h +++ b/include/config.h @@ -253,7 +253,6 @@ class Config #ifdef USE_QT_GUI_LOGIN bool bEnableLoginGUI; #endif - bool bListTags; // Cache bool bUseCache; diff --git a/include/downloader.h b/include/downloader.h index 4d37283..66e2f0d 100644 --- a/include/downloader.h +++ b/include/downloader.h @@ -96,7 +96,6 @@ class Downloader int init(); int login(); int listGames(); - int listTags(); void checkNotifications(); void clearUpdateNotifications(); void repair(); diff --git a/include/globalconstants.h b/include/globalconstants.h index 6749c27..e34d006 100644 --- a/include/globalconstants.h +++ b/include/globalconstants.h @@ -118,15 +118,17 @@ namespace GlobalConstants { CDN_AKAMAI, "akamai_edgecast_proxy", "Akamai", "akamai|akamai_cdn|akamai_ec|akamai_edgecast_proxy" } }; - const unsigned int LIST_FORMAT_NO_DETAILS = 1 << 0; + const unsigned int LIST_FORMAT_GAMES = 1 << 0; const unsigned int LIST_FORMAT_DETAILS_TEXT = 1 << 1; const unsigned int LIST_FORMAT_DETAILS_JSON = 1 << 2; + const unsigned int LIST_FORMAT_TAGS = 1 << 3; const std::vector LIST_FORMAT = { - { LIST_FORMAT_NO_DETAILS, "no_details", "No details", "n|nd|no_details" }, - { LIST_FORMAT_DETAILS_TEXT, "details", "Details", "d|details" }, - { LIST_FORMAT_DETAILS_JSON, "json", "JSON", "j|json" } + { LIST_FORMAT_GAMES, "games", "Games", "g|games" }, + { LIST_FORMAT_DETAILS_TEXT, "details", "Details", "d|details" }, + { LIST_FORMAT_DETAILS_JSON, "json", "JSON", "j|json" }, + { LIST_FORMAT_TAGS, "tags", "Tags", "t|tags" } }; } diff --git a/main.cpp b/main.cpp index 0ccc6a9..74805a8 100644 --- a/main.cpp +++ b/main.cpp @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) include_options_text += "Separate with \",\" to use multiple values"; // Create help text for --list-format option - std::string list_format_text = "List games\nPossible output formats:\n"; + std::string list_format_text = "List games/tags\n"; for (unsigned int i = 0; i < GlobalConstants::LIST_FORMAT.size(); ++i) { list_format_text += GlobalConstants::LIST_FORMAT[i].str + " = " + GlobalConstants::LIST_FORMAT[i].regexp + "\n"; @@ -217,7 +217,7 @@ int main(int argc, char *argv[]) ("help,h", "Print help message") ("version", "Print version information") ("login", bpo::value(&Globals::globalConfig.bLogin)->zero_tokens()->default_value(false), "Login") - ("list", bpo::value(&sListFormat)->implicit_value("no_details"), list_format_text.c_str()) + ("list", bpo::value(&sListFormat)->implicit_value("games"), list_format_text.c_str()) ("download", bpo::value(&Globals::globalConfig.bDownload)->zero_tokens()->default_value(false), "Download") ("repair", bpo::value(&Globals::globalConfig.bRepair)->zero_tokens()->default_value(false), "Repair downloaded files\nUse --repair --download to redownload files when filesizes don't match (possibly different version). Redownload will rename the old file (appends .old to filename)") ("game", bpo::value(&Globals::globalConfig.sGameRegex)->default_value(""), "Set regular expression filter\nfor download/list/repair (Perl syntax)") @@ -246,7 +246,6 @@ int main(int argc, char *argv[]) #ifdef USE_QT_GUI_LOGIN ("enable-login-gui", bpo::value(&Globals::globalConfig.bEnableLoginGUI)->zero_tokens()->default_value(false), "Enable login GUI when encountering reCAPTCHA on login form") #endif - ("list-tags", bpo::value(&Globals::globalConfig.bListTags)->zero_tokens()->default_value(false), "List tags") ("tag", bpo::value(&tags)->default_value(""), "Filter using tags. Separate with \",\" to use multiple values") ; // Commandline options (config file) @@ -795,10 +794,8 @@ int main(int argc, char *argv[]) downloader.repair(); else if (Globals::globalConfig.bDownload) // Download games downloader.download(); - else if (bList) // List games/extras + else if (bList) // List games/extras/tags res = downloader.listGames(); - else if (Globals::globalConfig.bListTags) // List tags - res = downloader.listTags(); else if (!Globals::globalConfig.sOrphanRegex.empty()) // Check for orphaned files if regex for orphans is set downloader.checkOrphans(); else if (Globals::globalConfig.bCheckStatus) diff --git a/src/downloader.cpp b/src/downloader.cpp index 3a5f6e1..1c51917 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -525,7 +525,7 @@ int Downloader::getGameDetails() int Downloader::listGames() { - if (Globals::globalConfig.iListFormat == GlobalConstants::LIST_FORMAT_NO_DETAILS) + if (Globals::globalConfig.iListFormat == GlobalConstants::LIST_FORMAT_GAMES) { if (gameItems.empty()) this->getGameList(); @@ -544,6 +544,19 @@ int Downloader::listGames() std::cout << "+> " << gameItems[i].dlcnames[j] << std::endl; } } + else if (Globals::globalConfig.iListFormat == GlobalConstants::LIST_FORMAT_TAGS) + { + std::map tags; + tags = gogWebsite->getTags(); + + if (!tags.empty()) + { + for (auto tag : tags) + { + std::cout << tag.first << " = " << tag.second << std::endl; + } + } + } else { if (this->games.empty()) { @@ -570,22 +583,6 @@ int Downloader::listGames() return 0; } -int Downloader::listTags() -{ - std::map tags; - tags = gogWebsite->getTags(); - - if (!tags.empty()) - { - for (auto tag : tags) - { - std::cout << tag.first << " = " << tag.second << std::endl; - } - } - - return 0; -} - void Downloader::repair() { if (this->games.empty())