Skip to content

Commit

Permalink
feat: add help and version options to ParseArgument class and update …
Browse files Browse the repository at this point in the history
…usage message
  • Loading branch information
MasterLaplace committed Dec 9, 2024
1 parent 8337e5f commit 3a2ead7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Flakkari/ParseArgument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ ParseArgument::ParseArgument(int ac, const char *av[])
_port = static_cast<unsigned short>(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())
Expand Down
10 changes: 6 additions & 4 deletions Flakkari/ParseArgument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ class ParseArgument {

static constexpr const char *HELP_MESSAGE =
"Usage: ./r-type_server <gameDir> <ip> <port>\n"
" <gameDir> The directory of the games folder\n"
" <ip> The ip to bind the server to (default: localhost)\n"
" <port> The port to bind the server to (default: 8081)\n"
" -h|--help Display this help message\n\n"
" <gameDir> The directory of the games folder\n"
" <ip> The ip to bind the server to (default: localhost)\n"
" <port> 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";
Expand Down

0 comments on commit 3a2ead7

Please sign in to comment.