1
0
Fork 0

Renamed fgParseOptions(int,string) to fgParseArgs, and modified the

function to allow property files as non-option parameters after the
options have finished (and added "--" to terminate options).  It's now
possible to do something like

  fgfs denver-am.fgd

or even

  fgfs at-lax.fgd in-c310.fgd around-sunset.fgd

This works the same way as the --config option, but will be friendlier
for GUIs, where start-up situation files can now be associated easily
with FlightGear.
This commit is contained in:
david 2002-01-04 20:58:48 +00:00
parent 3ddf66206a
commit 3cbc6f21c7
3 changed files with 25 additions and 13 deletions

View file

@ -288,7 +288,7 @@ bool fgInitConfig ( int argc, char **argv ) {
// Parse remaining command line options // Parse remaining command line options
// These will override anything specified in a config file // These will override anything specified in a config file
fgParseOptions(argc, argv); fgParseArgs(argc, argv);
return true; return true;
} }

View file

@ -1001,23 +1001,35 @@ fgScanForRoot (const string& path)
// Parse the command line options // Parse the command line options
void void
fgParseOptions (int argc, char **argv) { fgParseArgs (int argc, char **argv)
int i = 1; {
int result; bool in_options = true;
SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments"); SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
while ( i < argc ) { for (int i = 1; i < argc; i++) {
SG_LOG( SG_GENERAL, SG_DEBUG, "argv[" << i << "] = " << argv[i] ); string arg = argv[i];
result = parse_option(argv[i]); if (in_options && (arg.find('-') == 0)) {
if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) { if (arg == "--") {
in_options = false;
} else {
int result = parse_option(arg);
if ( (result == FG_OPTIONS_HELP) ||
(result == FG_OPTIONS_ERROR) ) {
fgUsage(); fgUsage();
exit(-1); exit(-1);
} }
i++;
} }
} else {
in_options = false;
SG_LOG(SG_GENERAL, SG_INFO,
"Reading command-line property file " << arg);
readProperties(arg, globals->get_props());
}
}
SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
} }

View file

@ -32,7 +32,7 @@
extern void fgSetDefaults (); extern void fgSetDefaults ();
extern string fgScanForRoot (int argc, char ** argv); extern string fgScanForRoot (int argc, char ** argv);
extern string fgScanForRoot (const string &file_path); extern string fgScanForRoot (const string &file_path);
extern void fgParseOptions (int argc, char ** argv); extern void fgParseArgs (int argc, char ** argv);
extern void fgParseOptions (const string &file_path); extern void fgParseOptions (const string &file_path);
extern void fgUsage (); extern void fgUsage ();