forked from markus/S_New4
v4.3.2: add colorless mode to updater
This commit is contained in:
parent
099a4a4dac
commit
3d87e301cc
@ -182,7 +182,7 @@ int PageManager::downLoadToFile(std::string filePath, std::string url)
|
||||
}
|
||||
|
||||
//Info ausgabe
|
||||
std::cout << ( "\33[2K\rDownloade: '" + url + "'..." + ((debugMode) ? "\n" : "" )) << std::flush;
|
||||
std::cout << ( "\33[2K\rDownloade: '" + url + "'..." + ((debugMode) ? "\n" : "" )) << "\33[2K\r" << std::flush;
|
||||
|
||||
/* init the curl session */
|
||||
curl_handle = curl_easy_init();
|
||||
|
@ -1260,6 +1260,7 @@ int unterOption_update(Settings *settings, int argc, char **argv)
|
||||
int c = 0;
|
||||
const option long_opts[] = {
|
||||
{"socks5-proxy", required_argument, nullptr, 'p'},
|
||||
{"colorless", no_argument, nullptr, 'c'},
|
||||
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"debug-mode", no_argument, nullptr, 'd'},
|
||||
@ -1268,12 +1269,17 @@ int unterOption_update(Settings *settings, int argc, char **argv)
|
||||
|
||||
};
|
||||
|
||||
while( ( c = getopt_long (argc, argv, "p:hd", long_opts, nullptr) ) != -1 ) {
|
||||
while( ( c = getopt_long (argc, argv, "p:chd", long_opts, nullptr) ) != -1 ) {
|
||||
switch(c) {
|
||||
case 'p':
|
||||
if(!optarg || setS5ProxytoSettings(*settings, optarg) != 0)
|
||||
return 2;
|
||||
break;
|
||||
case 'c':
|
||||
settings->colorless = true;
|
||||
if(settings->debugMode)
|
||||
std::cout << "Farblos: true" << std::endl;
|
||||
break;
|
||||
case 'h':
|
||||
unterOption_update_help(settings->programName);
|
||||
return -1;
|
||||
@ -1306,6 +1312,8 @@ void unterOption_update_help(std::string programName)
|
||||
<< " -p [ip:port/ip/port], --socks5-proxy [ip:port/ip/port]" << std::endl
|
||||
<< " Mit dieser Option kann man den Socks5Proxy ändern." << std::endl
|
||||
<< " Standart: 'Port 0' - Port 0 um Proxy zu deaktivieren." << std::endl << std::endl
|
||||
<< " -c, --colorless" << std::endl
|
||||
<< " Mit dieser Option kann man die farbige Ausgabe ausstellen." << std::endl << std::endl
|
||||
<< " -d, --debug-mode" << std::endl
|
||||
<< " Mit dieser Option kann man den Debug-Modus einschalten." << std::endl
|
||||
<< " Dabei werden vielmehr Infos ausgegeben." << std::endl << std::endl
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files="
|
||||
#define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files="
|
||||
#define VERSION "4.3.2"
|
||||
|
||||
|
||||
|
||||
enum Modus {
|
||||
@ -93,7 +95,7 @@ struct Settings {
|
||||
proxy_ip = "127.0.0.1",
|
||||
languages = "GerDub,GerSub,Eng,",
|
||||
genaueHoster = "",
|
||||
version = "4.3.0",
|
||||
version = VERSION,
|
||||
defaultFileVersion="1.8",
|
||||
default_checkPath = "",
|
||||
default_Searchmuster = "S%Staffel%E%Folge%";
|
||||
|
@ -1147,12 +1147,12 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
std::cout << " => INFO: Jetzige Version: '" << settings->version << "' - Neueste Version: '" << neusteVersion << "'" << std::endl;
|
||||
|
||||
//Print INFOs
|
||||
std::cout << " => Infos (zur Version): " << std::endl;
|
||||
std::cout << "\n => Infos (zur Version): " << std::endl;
|
||||
std::string line;
|
||||
std::stringstream strstream(html+ "\n");
|
||||
while (std::getline(strstream, line).good()) {
|
||||
if(line != "")
|
||||
std::cout << "\033[92m > " << line << "\033[0m" << std::endl;
|
||||
std::cout << ((settings->colorless) ? ("") : "\033[92m > ") << line << ((settings->colorless) ? ("") : "\033[0m") << std::endl;
|
||||
}
|
||||
|
||||
//Vergleiche Versionen:
|
||||
@ -1175,7 +1175,7 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
std::string downloadedFilePath = settings->cacheDir + "NeusteVersion" + ((settings->pathSymbol == '\\') ? ".exe" : "");
|
||||
|
||||
//wenn dort schon eine datei existiert, lösche diese
|
||||
std::cout << " => INFO: Lösche Download-Datei, fallst bereits eine vorhanden ist..." << std::endl;
|
||||
std::cout << "\n => INFO: Bereinige Downloadpfad, falls alte Dateien vorhanden sind..." << std::endl;
|
||||
if(fileExists(downloadedFilePath)) {
|
||||
if(remove(downloadedFilePath.c_str()) != 0) {
|
||||
perror((" => Error: Das löschen der Datei '" + downloadedFilePath + "' ist fehlgeschlagen").c_str());
|
||||
@ -1208,7 +1208,7 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
#endif
|
||||
|
||||
//Führe neue Version aus und überprüfe rückgabewert
|
||||
std::cout << " => INFO: Überprüfe die Funktionalität der neuen Version..." << std::endl;
|
||||
std::cout << " => INFO: Überprüfe die Funktionalität der neuen Version...\n" << std::endl;
|
||||
|
||||
if( system((downloadedFilePath + " --version" ).c_str()) != 0) {
|
||||
std::cerr << (" => Error: Ausführen der neuen Version ist fehlgeschlagen") << std::endl;
|
||||
@ -1226,7 +1226,7 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
std::string oldVersionPah = settings->cacheDir + "oldVersion" + ((settings->pathSymbol == '\\') ? ".exe" : "");
|
||||
|
||||
//lösche falls vorhanden altes backup
|
||||
std::cout << " => INFO: Lösche alte Nofall Version falls vorhanden..." << std::endl;
|
||||
std::cout << "\n => INFO: Lösche alte Nofall Version falls vorhanden..." << std::endl;
|
||||
if(fileExists(oldVersionPah)) {
|
||||
if(remove( oldVersionPah.c_str() ) != 0) {
|
||||
perror((" => Error: Das löschen der Datei '" + oldVersionPah + "' ist fehlgeschlagen.").c_str());
|
||||
@ -1255,7 +1255,8 @@ int ProgramManager::updateModus(Settings *settings)
|
||||
<< downloadedFilePath << "' -> '" << exePath << "'" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "\n => Update Erfolgreich ausgeführt: '" << settings->version << "' -> '" << neusteVersion << "'" << std::endl;
|
||||
std::cout << ((settings->colorless) ? ("") : "\033[92m") << "\n => Update Erfolgreich ausgeführt: '" << settings->version <<
|
||||
"' -> '" << neusteVersion << "'" << ((settings->colorless) ? ("") : "\033[0m") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user