DynuIPRefresher/src/main.cpp

43 lines
1.6 KiB
C++
Raw Normal View History

2019-05-05 13:38:48 +00:00
#include <iostream>
#include <IPRefresher.h>
2019-10-26 12:41:43 +00:00
#include <Version.h>
#include <Logger.h>
#include <Credentials.h>
2019-05-05 13:38:48 +00:00
2019-05-06 10:55:01 +00:00
int main(int argc, char *argv[]) {
2019-05-06 16:49:38 +00:00
if (argc > 1) {
2019-05-06 10:55:01 +00:00
std::string firstarg(argv[1]);
2019-05-06 16:49:38 +00:00
if (firstarg == "-h" || firstarg == "--help") {
std::cout << "help page: " << std::endl << "[-h] [--help] print this help page" << std::endl
<< "[-v] [--version] print the software version" << std::endl
<< "[-f] [--force] force refresh of ip" << std::endl
<< "[-l] [--loop] infinite loop to refresh ip every five minutes" << std::endl
2019-05-06 16:49:38 +00:00
<< "[no argument] normal ip check and refresh" << std::endl;
} else if (firstarg == "-v" || firstarg == "--version") {
std::cout << "Version " << Version::VERSION << std::endl;
} else if (firstarg == "-f" || firstarg == "--force") {
IPRefresher ipr;
2020-04-30 09:30:41 +00:00
if (Credentials::readCredentials()) {
ipr.checkIPAdress(true);
} else {
std::cout << "incorrect credentials!" << std::endl;
}
} else if (firstarg == "-l" || firstarg == "--loop") {
2020-02-11 16:22:14 +00:00
IPRefresher(true);
2019-05-06 16:49:38 +00:00
} else {
2019-10-26 12:41:43 +00:00
Logger::message("wrong arguments! -h for help");
2019-05-06 10:55:01 +00:00
}
2019-05-06 16:49:38 +00:00
} else {
IPRefresher ipr;
2019-10-26 12:41:43 +00:00
Logger::message("starting check");
2020-04-30 09:30:41 +00:00
if (Credentials::readCredentials()) {
ipr.checkIPAdress(false);
} else {
std::cout << "incorrect credentials!" << std::endl;
}
2019-05-05 16:50:10 +00:00
}
2019-05-05 13:38:48 +00:00
return 0;
}