X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=3cf7bf94c97d26d358b0ee97f90d07fc97a16f5a;hb=bd6bd2c875f4b6baef913e5315aa9f7e7cd7da7a;hp=f9bc154739fa57a0045f8e6bbd991782367cc9d7;hpb=774253e509ce13881229efda8849bf6f3c47b665;p=blank.git diff --git a/src/main.cpp b/src/main.cpp index f9bc154..3cf7bf9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,86 +1,9 @@ -#include "app.hpp" - -#include -#include -#include +#include "runtime.hpp" using namespace blank; - -namespace { - -enum Mode { - NORMAL, - FRAME_LIMIT, - TIME_LIMIT, - FIXED_FRAME_LIMIT, -}; - -} - - int main(int argc, char *argv[]) { - - Mode mode = NORMAL; - size_t n = 0, t = 0; - - bool error = false; - for (int i = 1; i < argc; ++i) { - if (argv[i] == nullptr || argv[i][0] == '\0') continue; - if (argv[i][0] == '-') { - if (argv[i][1] == 't' && argv[i][2] == '\0') { - ++i; - if (i >= argc) { - std::cerr << "missing argument to -t" << std::endl; - error = true; - } else { - t = std::strtoul(argv[i], nullptr, 10); - } - } else { - std::cerr << "unable to interpret argument " - << i << " (" << argv[i] << ")" << std::endl; - error = true; - } - } else if (std::isdigit(*argv[i])) { - n = std::strtoul(argv[i], nullptr, 10); - } else { - std::cerr << "unable to interpret argument " - << i << " (" << argv[i] << ")" << std::endl; - error = true; - } - } - - if (error) { - return 1; - } - - if (n > 0) { - if (t > 0) { - mode = FIXED_FRAME_LIMIT; - } else { - mode = FRAME_LIMIT; - } - } else if (t > 0) { - mode = TIME_LIMIT; - } - - Application app; - switch (mode) { - default: - case NORMAL: - app.Run(); - break; - case FRAME_LIMIT: - app.RunN(n); - break; - case TIME_LIMIT: - app.RunT(t); - break; - case FIXED_FRAME_LIMIT: - app.RunS(n, t); - break; - } - - return 0; - + Runtime rt; + rt.ReadArgs(argc, argv); + return rt.Execute(); }