Skip to content

Commit

Permalink
Merge pull request #482 from OoliteProject/helpOnCmdLine
Browse files Browse the repository at this point in the history
Introducing -help / --help Command Line Option
  • Loading branch information
AnotherCommander committed May 24, 2024
2 parents e8a2937 + e208e1a commit db7caf1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Doc/CHANGELOG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ General:
* (Windows) Required minimum OS is now Windows 7.
* Minimum OpenGL version is now 3.3.
* Application startup command is now written to the log file.
* Implemented [-]-help command line option - shows list of available command line
switches.

Expansion Pack Development:
===========================
Expand Down
36 changes: 35 additions & 1 deletion src/SDL/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ int main(int argc, char *argv[])

#if OOLITE_WINDOWS

// Detect current working directory and set up GNUstep environment variables
#define OO_SHOW_MSG(ooMsg, ooMsgTitle, ooMsgFlags) MessageBox(NULL, ooMsg, ooMsgTitle, ooMsgFlags)

// Detect current working directory and set up GNUstep environment variables
#define MAX_PATH_LEN 256
char currentWorkingDir[MAX_PATH_LEN];
char envVarString[2 * MAX_PATH_LEN];
Expand Down Expand Up @@ -108,6 +110,9 @@ int main(int argc, char *argv[])
numbers don't behave strangely.
*/
setlocale(LC_ALL, "C");

#else // Linux
#define OO_SHOW_MSG(ooMsg, ooTitle, ooFlags) fprintf(stdout, ooMsg)
#endif

// Need this because we're not using the default run loop's autorelease
Expand All @@ -129,6 +134,35 @@ int main(int argc, char *argv[])
if (i < argc)
[controller setPlayerFileToLoad: [NSString stringWithCString: argv[i]]];
}

if (!strcmp("-help", argv[i]) || !strcmp("--help", argv[i]))
{
char const *processName = [[[NSProcessInfo processInfo] processName] UTF8String];
char s[2048];
snprintf(s, sizeof(s), "Usage: %s [options]\n\n"
"Options can be any of the following: \n\n"
"--compile-sysdesc\t\t\tCompile system descriptions *\n"
"--export-sysdesc\t\t\tExport system descriptions *\n"
#if OOLITE_WINDOWS
"-hdr\t\t\t\tStart up in HDR mode\n"
#endif
"-load [filepath]:\t\t\tLoad commander from [filepath]\n"
"-message [messageString]\t\tDisplay [messageString] at startup\n"
"-noshaders\t\t\tStart up with shaders disabled\n"
"-nosplash\t\t\t\tForce disable splash screen on startup\n"
"-nosound\t\t\t\tStart up with sound disabled\n"
"-novsync\t\t\t\tForce disable V-Sync\n"
"--openstep\t\t\tWhen compiling or exporting system\n\t\t\t\tdescriptions, use openstep format *\n"
"-showversion\t\t\tDisplay version at startup screen\n"
"-splash\t\t\t\tForce splash screen on startup\n"
"-verify-oxp [filepath]\t\t\tVerify OXP at [filepath] *\n"
"--xml\t\t\t\tWhen compiling or exporting system \n\t\t\t\tdescriptions, use xml format *\n"
"\n"
"Options marked with \"*\" are available only in Test Release configuration.\n\n", processName);
OO_SHOW_MSG(s, processName, MB_OK);
OOLog(@"process.args", @"%s option detected, exiting after help page has been displayed.", argv[i]);
return 0;
}
}

// Release anything allocated during the controller initialisation that
Expand Down

0 comments on commit db7caf1

Please sign in to comment.