Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Obara <dreamer.tan@gmail.com>2022-05-14 17:01:57 +0300
committerPatryk Obara <dreamer.tan@gmail.com>2022-05-14 17:01:57 +0300
commit7e64b3e8f8e6657a6c237f9deb45d3dcda9c6665 (patch)
tree74109e4ee98fb7a9546c52ca6775bc7148b558e0
parent0801bc7fce83c792f7eb17f1b1e9adcb64ba101f (diff)
Handle --version and --help before loguru initpo/tame-help-logging
Loguru is great library for logging, but it's introduction caused a small issue: excessive logging for several parameters that should just print something on output and exit. Both --version and --help should just print what they are supposed to print and exit, without excessive logs about initialization of several subsystems. Same should also happen for --printconf and --list-glshaders but it's impossible now because in some cases these functionalities log errors. However, primary usecase for --printconf is handling in scripts (and it still works fine because loguru prints to stderr), and --list-glshaders outputs enough text to be readable despite additional loguru logs.
-rw-r--r--src/gui/sdlmain.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp
index 51ecb557a..4199de3ab 100644
--- a/src/gui/sdlmain.cpp
+++ b/src/gui/sdlmain.cpp
@@ -4378,9 +4378,24 @@ void GFX_GetSize(int &width, int &height, bool &fullscreen)
extern "C" int SDL_CDROMInit(void);
int sdl_main(int argc, char *argv[])
{
- int rcode = 0; // assume good until proven otherwise
-
- // Setup logging right away
+ CommandLine com_line(argc, argv);
+ control = std::make_unique<Config>(&com_line);
+
+ if (control->cmdline->FindExist("--version") ||
+ control->cmdline->FindExist("-version") ||
+ control->cmdline->FindExist("-v")) {
+ printf(version_msg, DOSBOX_GetDetailedVersion());
+ return 0;
+ }
+
+ if (control->cmdline->FindExist("--help") ||
+ control->cmdline->FindExist("-help") ||
+ control->cmdline->FindExist("-h")) {
+ printf(help_msg); // -V618
+ return 0;
+ }
+
+ // Setup logging after commandline is parsed and trivial arguments handled
loguru::g_preamble_date = true; // The date field
loguru::g_preamble_time = true; // The time of the current day
loguru::g_preamble_uptime = false; // The time since init call
@@ -4397,16 +4412,13 @@ int sdl_main(int argc, char *argv[])
LOG_MSG("LOG: Loguru version %d.%d.%d initialized", LOGURU_VERSION_MAJOR,
LOGURU_VERSION_MINOR, LOGURU_VERSION_PATCH);
+ int rcode = 0; // assume good until proven otherwise
try {
Disable_OS_Scaling(); //Do this early on, maybe override it through some parameter.
OverrideWMClass(); // Before SDL2 video subsystem is initialized
CROSS_DetermineConfigPaths();
- CommandLine com_line(argc,argv);
-
- control = std::make_unique<Config>(&com_line);
-
/* Init the configuration system and add default values */
Config_Add_SDL();
DOSBOX_Init();
@@ -4447,21 +4459,6 @@ int sdl_main(int argc, char *argv[])
}
#endif //defined(WIN32) && !(C_DEBUG)
- if (control->cmdline->FindExist("--version") ||
- control->cmdline->FindExist("-version") ||
- control->cmdline->FindExist("-v")) {
- printf(version_msg, DOSBOX_GetDetailedVersion());
- return 0;
- }
-
- //If command line includes --help or -h, print help message and exit.
- if (control->cmdline->FindExist("--help") ||
- control->cmdline->FindExist("-help") ||
- control->cmdline->FindExist("-h")) {
- printf(help_msg); // -V618
- return 0;
- }
-
if (control->cmdline->FindExist("--printconf") ||
control->cmdline->FindExist("-printconf")) {
const int err = PrintConfigLocation();