From 3a2ead73e7c94955394a1d803ad46a56d3800174 Mon Sep 17 00:00:00 2001 From: MasterLaplace Date: Mon, 9 Dec 2024 12:23:49 -0500 Subject: [PATCH] feat: add help and version options to ParseArgument class and update usage message --- Flakkari/ParseArgument.cpp | 10 ++++++++++ Flakkari/ParseArgument.hpp | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Flakkari/ParseArgument.cpp b/Flakkari/ParseArgument.cpp index c0a833a..9bf67f5 100644 --- a/Flakkari/ParseArgument.cpp +++ b/Flakkari/ParseArgument.cpp @@ -37,6 +37,16 @@ ParseArgument::ParseArgument(int ac, const char *av[]) _port = static_cast(std::stoi(av[i + 1])); ++i; } + else if (std::string(av[i]) == "-h" || std::string(av[i]) == "--help") + { + std::cout << HELP_MESSAGE << std::endl; + exit(0); + } + else if (std::string(av[i]) == "-v" || std::string(av[i]) == "--version") + { + std::cout << "Flakkari Library v" FLAKKARI_VERSION_STRING " - © 2024 MasterLaplace" << std::endl; + exit(0); + } } if (_ip.empty()) diff --git a/Flakkari/ParseArgument.hpp b/Flakkari/ParseArgument.hpp index 563c4d4..dd40a56 100644 --- a/Flakkari/ParseArgument.hpp +++ b/Flakkari/ParseArgument.hpp @@ -53,10 +53,12 @@ class ParseArgument { static constexpr const char *HELP_MESSAGE = "Usage: ./r-type_server \n" - " The directory of the games folder\n" - " The ip to bind the server to (default: localhost)\n" - " The port to bind the server to (default: 8081)\n" - " -h|--help Display this help message\n\n" + " The directory of the games folder\n" + " The ip to bind the server to (default: localhost)\n" + " The port to bind the server to (default: 8081)\n" + " -d|--default Use default values (Games, localhost, 8081)\n" + " -v|--version Display the version of the Flakkari Library\n" + " -h|--help Display this help message\n\n" "Example: ./r-type_server Games localhost 8081\n\n" "More information at https://github.com/MasterLaplace/Falkkari\n" "Flakkari Library v" FLAKKARI_VERSION_STRING " - © 2024 MasterLaplace\n";