#include "application.h" #include "output_util.h" #include #include #include constexpr static int MIN_ARGC = 2; constexpr static int MAX_ARGC = 4; static std::tuple error(const char* msg) { std::cout << msg; return {EXIT_FAILURE, 0, {}}; } static std::tuple parseInput(int argc, char **argv) { int splitting = -1; std::string path; switch (argc) { default: return error(output::NO_ARG_MSG); case MIN_ARGC: // maybe --help if (strcmp(argv[1], output::HELP_FLAG) == 0) return error(output::HELP_MSG); /* HERE PARSE FILEPATH INSTEAD */ return error(output::NO_ARG_MSG); break; case (MAX_ARGC - 1): case MAX_ARGC: // full stack if (strcmp(argv[1], output::SPLITTING_FLAG) == 0) { if (std::isdigit(*argv[2])) splitting = std::stoi(argv[2]); if (splitting < 1) return error(output::SPLITTING_MSG); /* HERE PARSE FILEPATH INSTEAD */ return error(output::NO_ARG_MSG); } return error(output::NO_ARG_MSG); break; } return {EXIT_SUCCESS, splitting, path}; } int main(int argc, char **argv) { auto[ret_code, splitting, path] = parseInput(argc, argv); if (ret_code) // Error code is EXIT_FAILURE return ret_code; Application app; if (app.init(splitting, path)) { app.run(); return EXIT_SUCCESS; } return EXIT_FAILURE; }