// // Created by lukas on 18.06.19. // #include #include #include #include #include /** * application entry point */ int main(int argc, char *argv[]) { if (argc > 1) { std::string firstarg(argv[1]); 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 << "[-c] [--checkconfig] validate configuration" << std::endl << "[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; if (Config::readCredentials()) { ipr.checkIPAdress(true); } else { std::cout << "incorrect credentials!" << std::endl; } } else if (firstarg == "-l" || firstarg == "--loop") { IPRefresher(true); } else if (firstarg == "-c" || firstarg == "--checkconfig") { if (Config::validateConfig()) { Logger::message("Config file is OK"); } else { Logger::warning("There are errors in config file!"); return -1; } } else { Logger::message("wrong arguments! -h for help"); } } else { IPRefresher ipr; Logger::message("starting check"); if (Config::readCredentials()) { ipr.checkIPAdress(false); } else { std::cout << "incorrect credentials!" << std::endl; } } return 0; }