Add CLI help message, accessible with --help (#614)

* Add CLI --help argument

* Make clang-format happy

* Move to switch instead of creating temp var

* Remove unnecesary break

Co-authored-by: Christian Semmler <mail@csemmler.com>

* Remove unnecesary break 2

Co-authored-by: Christian Semmler <mail@csemmler.com>

* Make clang-format happy again

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
VoxelTek 2025-07-16 10:29:42 +10:00 committed by GitHub
parent ad2832b096
commit b6a4f65db4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 5 deletions

View File

@ -315,7 +315,8 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
// Create global app instance // Create global app instance
g_isle = new IsleApp(); g_isle = new IsleApp();
if (g_isle->ParseArguments(argc, argv) != SUCCESS) { switch (g_isle->ParseArguments(argc, argv)) {
case SDL_APP_FAILURE:
Any_ShowSimpleMessageBox( Any_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR, SDL_MESSAGEBOX_ERROR,
"LEGO® Island Error", "LEGO® Island Error",
@ -323,6 +324,10 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
window window
); );
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
case SDL_APP_SUCCESS:
return SDL_APP_SUCCESS;
case SDL_APP_CONTINUE:
break;
} }
// Create window // Create window
@ -1301,7 +1306,7 @@ void IsleApp::SetupCursor(Cursor p_cursor)
} }
} }
MxResult IsleApp::ParseArguments(int argc, char** argv) SDL_AppResult IsleApp::ParseArguments(int argc, char** argv)
{ {
for (int i = 1, consumed; i < argc; i += consumed) { for (int i = 1, consumed; i < argc; i += consumed) {
consumed = -1; consumed = -1;
@ -1318,13 +1323,29 @@ MxResult IsleApp::ParseArguments(int argc, char** argv)
#endif #endif
consumed = 1; consumed = 1;
} }
else if (strcmp(argv[i], "--help") == 0) {
DisplayArgumentHelp();
return SDL_APP_SUCCESS;
}
if (consumed <= 0) { if (consumed <= 0) {
SDL_Log("Invalid argument(s): %s", argv[i]); SDL_Log("Invalid argument(s): %s", argv[i]);
return FAILURE; DisplayArgumentHelp();
return SDL_APP_FAILURE;
} }
} }
return SUCCESS; return SDL_APP_CONTINUE;
}
void IsleApp::DisplayArgumentHelp()
{
SDL_Log("Usage: isle [options]");
SDL_Log("Options:");
SDL_Log(" --ini <path> Set custom path to .ini config");
#ifdef ISLE_DEBUG
SDL_Log(" --debug Launch in debug mode");
#endif
SDL_Log(" --help Show this help message");
} }
MxResult IsleApp::VerifyFilesystem() MxResult IsleApp::VerifyFilesystem()

View File

@ -61,7 +61,7 @@ class IsleApp {
void SetGameStarted(MxS32 p_gameStarted) { m_gameStarted = p_gameStarted; } void SetGameStarted(MxS32 p_gameStarted) { m_gameStarted = p_gameStarted; }
void SetDrawCursor(MxS32 p_drawCursor) { m_drawCursor = p_drawCursor; } void SetDrawCursor(MxS32 p_drawCursor) { m_drawCursor = p_drawCursor; }
MxResult ParseArguments(int argc, char** argv); SDL_AppResult ParseArguments(int argc, char** argv);
MxResult VerifyFilesystem(); MxResult VerifyFilesystem();
void DetectGameVersion(); void DetectGameVersion();
void MoveVirtualMouseViaJoystick(); void MoveVirtualMouseViaJoystick();
@ -99,6 +99,7 @@ class IsleApp {
const CursorBitmap* m_cursorCurrentBitmap; const CursorBitmap* m_cursorCurrentBitmap;
char* m_mediaPath; char* m_mediaPath;
MxFloat m_cursorSensitivity; MxFloat m_cursorSensitivity;
void DisplayArgumentHelp();
char* m_iniPath; char* m_iniPath;
MxFloat m_maxLod; MxFloat m_maxLod;