aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/config.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-11-15 15:46:00 +0100
committerGitHub <[email protected]>2023-11-15 15:46:00 +0100
commit9db70b8b27df7690b061d0a002b5a67b84c474cf (patch)
treea7c5c0e5952ffe40a0be390203aa97b50618755a /src/zenserver/config.cpp
parentUpdate README.md (diff)
downloadzen-9db70b8b27df7690b061d0a002b5a67b84c474cf.tar.xz
zen-9db70b8b27df7690b061d0a002b5a67b84c474cf.zip
remove dependency on cxxopts exception types (#542)
changed options parsing so that we don't depend on cxxopts exception types this makes it possible to use any cxxopts-version including beyond 3.0.0
Diffstat (limited to 'src/zenserver/config.cpp')
-rw-r--r--src/zenserver/config.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp
index 08ba6dc95..e7edd5745 100644
--- a/src/zenserver/config.cpp
+++ b/src/zenserver/config.cpp
@@ -1337,9 +1337,18 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
try
{
- auto result = options.parse(argc, argv);
+ cxxopts::ParseResult Result;
- if (result.count("help"))
+ try
+ {
+ Result = options.parse(argc, argv);
+ }
+ catch (std::exception& Ex)
+ {
+ throw zen::OptionParseException(Ex.what());
+ }
+
+ if (Result.count("help"))
{
ZEN_CONSOLE("{}", options.help());
#if ZEN_PLATFORM_WINDOWS
@@ -1373,21 +1382,15 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions)
if (!ServerOptions.ConfigFile.empty())
{
- ParseConfigFile(ServerOptions.ConfigFile, ServerOptions, result, OutputConfigFile);
+ ParseConfigFile(ServerOptions.ConfigFile, ServerOptions, Result, OutputConfigFile);
}
else
{
- ParseConfigFile(ServerOptions.DataDir / "zen_cfg.lua", ServerOptions, result, OutputConfigFile);
+ ParseConfigFile(ServerOptions.DataDir / "zen_cfg.lua", ServerOptions, Result, OutputConfigFile);
}
ValidateOptions(ServerOptions);
}
- catch (cxxopts::OptionParseException& e)
- {
- ZEN_CONSOLE_ERROR("Error parsing zenserver arguments: {}\n\n{}", e.what(), options.help());
-
- throw;
- }
catch (zen::OptionParseException& e)
{
ZEN_CONSOLE_ERROR("Error parsing zenserver arguments: {}\n\n{}", e.what(), options.help());