]> git.mxchange.org Git - flightgear.git/commitdiff
Renamed fgParseOptions(int,string) to fgParseArgs, and modified the
authordavid <david>
Fri, 4 Jan 2002 20:58:48 +0000 (20:58 +0000)
committerdavid <david>
Fri, 4 Jan 2002 20:58:48 +0000 (20:58 +0000)
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.

src/Main/fg_init.cxx
src/Main/options.cxx
src/Main/options.hxx

index ec6039b60c138f5ac66a9391a186744215e5d224..f804c2070b1cdeff957529312bd88bcc058b1ad3 100644 (file)
@@ -288,7 +288,7 @@ bool fgInitConfig ( int argc, char **argv ) {
 
     // Parse remaining command line options
     // These will override anything specified in a config file
-    fgParseOptions(argc, argv);
+    fgParseArgs(argc, argv);
 
     return true;
 }
index e5eedb048113306b7f334a83c3f1b8d2f156eb7e..f7931419e9104e323ee3ed389e8743c0ddd2beab 100644 (file)
@@ -1001,23 +1001,35 @@ fgScanForRoot (const string& path)
 
 // Parse the command line options
 void
-fgParseOptions (int argc, char **argv) {
-    int i = 1;
-    int result;
+fgParseArgs (int argc, char **argv)
+{
+    bool in_options = true;
 
     SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
 
-    while ( i < argc ) {
-       SG_LOG( SG_GENERAL, SG_DEBUG, "argv[" << i << "] = " << argv[i] );
-
-       result = parse_option(argv[i]);
-       if ( (result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR) ) {
-           fgUsage();
-           exit(-1);
+    for (int i = 1; i < argc; i++) {
+        string arg = argv[i];
+
+       if (in_options && (arg.find('-') == 0)) {
+         if (arg == "--") {
+           in_options = false;
+         } else {
+           int result = parse_option(arg);
+           if ( (result == FG_OPTIONS_HELP) ||
+                (result == FG_OPTIONS_ERROR) ) {
+             fgUsage();
+             exit(-1);
+           }
+         }
+       } else {
+         in_options = false;
+         SG_LOG(SG_GENERAL, SG_INFO,
+                "Reading command-line property file " << arg);
+         readProperties(arg, globals->get_props());
        }
-
-       i++;
     }
+
+    SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
 }
 
 
index 36128137b0fd4dc028128e0265a4626f70c9f8a2..b4ecc9f82e81092dc36b6eb83f29707614cb2d82 100644 (file)
@@ -32,7 +32,7 @@
 extern void fgSetDefaults ();
 extern string fgScanForRoot (int argc, char ** argv);
 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 fgUsage ();