#include "Web_Server.h" #include #include #include #include namespace { std::uint16_t parse_port(int argc, char** argv) { constexpr std::uint16_t default_port = 8848; if (argc != 3 || std::string_view(argv[1]) != "--port") return default_port; unsigned value{}; const std::string_view text(argv[2]); const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), value); if (error != std::errc{} || end != text.data() + text.size() || value == 0 || value > 65535) { std::cerr << "Invalid port: " << text << '\n'; return 0; } return static_cast(value); } } // namespace int main(int argc, char** argv) { const std::uint16_t port = parse_port(argc, argv); return port == 0 ? 2 : renderive::web::run_web_server(port); }