diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-13 22:57:56 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:45:00 +0800 |
| commit | aa37277b893d1bfe589618665f355495082e05b6 (patch) | |
| tree | 1d2be3784346ccaf211a08ad07873846d3519b4d /src/main.cpp | |
| parent | bcf30ffc53d7cf007f0bcd1ba9aca44fe2a2acde (diff) | |
clang-format & clang-tidy
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8b32a44..6b813e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,45 +30,45 @@ static void registerSignals() { } static void help() { - log(ERR, "usage: chat-server <port>"); + log(ERR, "usage: chat-server <port>"); } // TODO: ARGC, ARGV. the CServer ctor should take a port number int main(int argc, char *argv[]) { std::vector<std::string> args{argv + 1, argv + argc}; - if (args.empty()) { - help(); - - return EXIT_FAILURE; - } - uint16_t port = 0; - for (const auto &arg : args) { - if (arg == "-h" || arg == "--help") { - help(); - return EXIT_SUCCESS; - } else if (std::ranges::all_of(arg, ::isdigit)) { - port = std::stoi(arg); - if (std::stoi(arg) < 0) { - log(ERR, "Port number must be greater than 0"); - - return EXIT_FAILURE; - } else if (std::stoi(arg) > 65535) { - log(ERR, "Port number must be less than 65536"); - - return EXIT_FAILURE; - } - - port = std::stoi(arg); - log(LOG, "Port number: {}", port); - } - } - - if (port == 0) { - log(ERR, "Port number is required"); - - help(); - return EXIT_FAILURE; - } + if (args.empty()) { + help(); + + return EXIT_FAILURE; + } + uint16_t port = 0; + for (const auto &arg : args) { + if (arg == "-h" || arg == "--help") { + help(); + return EXIT_SUCCESS; + } else if (std::ranges::all_of(arg, ::isdigit)) { + port = std::stoi(arg); + if (std::stoi(arg) < 0) { + log(ERR, "Port number must be greater than 0"); + + return EXIT_FAILURE; + } else if (std::stoi(arg) > 65535) { + log(ERR, "Port number must be less than 65536"); + + return EXIT_FAILURE; + } + + port = std::stoi(arg); + log(LOG, "Port number: {}", port); + } + } + + if (port == 0) { + log(ERR, "Port number is required"); + + help(); + return EXIT_FAILURE; + } registerSignals(); |
