mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-01 21:42:31 +01:00
Make --list able to list tags
Removed --list-tags option Also changed the default option name "no_details" to "games"
This commit is contained in:
parent
9d188e73bd
commit
20cce5abbb
@ -253,7 +253,6 @@ class Config
|
||||
#ifdef USE_QT_GUI_LOGIN
|
||||
bool bEnableLoginGUI;
|
||||
#endif
|
||||
bool bListTags;
|
||||
|
||||
// Cache
|
||||
bool bUseCache;
|
||||
|
@ -96,7 +96,6 @@ class Downloader
|
||||
int init();
|
||||
int login();
|
||||
int listGames();
|
||||
int listTags();
|
||||
void checkNotifications();
|
||||
void clearUpdateNotifications();
|
||||
void repair();
|
||||
|
@ -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<optionsStruct> LIST_FORMAT =
|
||||
{
|
||||
{ LIST_FORMAT_NO_DETAILS, "no_details", "No details", "n|nd|no_details" },
|
||||
{ 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_DETAILS_JSON, "json", "JSON", "j|json" },
|
||||
{ LIST_FORMAT_TAGS, "tags", "Tags", "t|tags" }
|
||||
};
|
||||
}
|
||||
|
||||
|
9
main.cpp
9
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<bool>(&Globals::globalConfig.bLogin)->zero_tokens()->default_value(false), "Login")
|
||||
("list", bpo::value<std::string>(&sListFormat)->implicit_value("no_details"), list_format_text.c_str())
|
||||
("list", bpo::value<std::string>(&sListFormat)->implicit_value("games"), list_format_text.c_str())
|
||||
("download", bpo::value<bool>(&Globals::globalConfig.bDownload)->zero_tokens()->default_value(false), "Download")
|
||||
("repair", bpo::value<bool>(&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<std::string>(&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<bool>(&Globals::globalConfig.bEnableLoginGUI)->zero_tokens()->default_value(false), "Enable login GUI when encountering reCAPTCHA on login form")
|
||||
#endif
|
||||
("list-tags", bpo::value<bool>(&Globals::globalConfig.bListTags)->zero_tokens()->default_value(false), "List tags")
|
||||
("tag", bpo::value<std::string>(&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)
|
||||
|
@ -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<std::string, std::string> 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<std::string, std::string> 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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user