#include #include #include #include "argparse/argparse.hpp" #include "EventManager.hpp" int main(int argc, char* argv[]) { // initialize the mpg123 library if (mpg123_init() != MPG123_OK) throw std::runtime_error("Error while initializing mpg123."); // initialize the PortAudio library if (Pa_Initialize() != paNoError) throw std::runtime_error("Could not initialize PortAudio."); argparse::ArgumentParser parser("Program"); parser.add_argument("-h", "--host").help("Host address").default_value(std::string("127.0.0.1")); parser.add_argument("-p", "--port").help("Port").default_value(std::string("15650")); parser.add_argument("-6", "--ipv6").help("Use IPv6").flag(); try { parser.parse_args(argc, argv); } catch (const std::exception& exception) { std::cerr << exception.what() << std::endl; return EXIT_FAILURE; } auto eventManager = EventManager( parser.get("--host"), parser.get("--port"), parser.get("-6") ); eventManager.loop(); // terminate the libraries Pa_Terminate(); mpg123_exit(); return EXIT_SUCCESS; }