Revision: 7571
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7571&view=rev
Author:   rtv
Date:     2009-04-02 23:50:59 +0000 (Thu, 02 Apr 2009)

Log Message:
-----------
cleaned up cmdline args

Modified Paths:
--------------
    code/stage/trunk/libstage/main.cc
    code/stage/trunk/libstage/model_draw.cc
    code/stage/trunk/libstage/powerpack.cc
    code/stage/trunk/worlds/simple.world

Modified: code/stage/trunk/libstage/main.cc
===================================================================
--- code/stage/trunk/libstage/main.cc   2009-04-02 01:04:09 UTC (rev 7570)
+++ code/stage/trunk/libstage/main.cc   2009-04-02 23:50:59 UTC (rev 7571)
@@ -10,12 +10,20 @@
 #include "config.h"
 using namespace Stg;
 
+const char* USAGE = 
+  "USAGE:  stage [options] [<worldfile>]\n"
+  "Available [options] are:\n"
+  "  --gui          : run without a GUI (same as -g)\n"
+  "  -g             : run without a GUI (same as --gui)\n"
+  "  --help         : print this message.\n"
+  "  -h             : print this message.\n"
+  "  -?             : print this message.\n"
+  " If <worldfile> is not specified, Stage starts with a file selector dialog";
+
 /* options descriptor */
 static struct option longopts[] = {
        { "gui",  optional_argument,   NULL,  'g' },
-       { "port",  required_argument,   NULL,  'p' },
-       { "host",  required_argument,   NULL,  'h' },
-       { "federation",  required_argument,   NULL,  'f' },
+       { "help",  optional_argument,   NULL,  'h' },
        { NULL, 0, NULL, 0 }
 };
 
@@ -29,7 +37,7 @@
   int ch=0, optindex=0;
   bool usegui = true;
   
-  while ((ch = getopt_long(argc, argv, "gfp:h:f:", longopts, &optindex)) != -1)
+  while ((ch = getopt_long(argc, argv, "gh?", longopts, &optindex)) != -1)
         {
                switch( ch )
                  {
@@ -40,12 +48,15 @@
                         usegui = false;
                         printf( "[GUI disabled]" );
                         break;
-                 case 'p':
-                        printf( "PORT %d\n", atoi(optarg) );
+                 case 'h':  
                  case '?':  
+                        puts( USAGE );
+                        exit(0);
                         break;
                  default:
                         printf("unhandled option %c\n", ch );
+                        puts( USAGE );
+                        exit(0);
                  }
         }
   
@@ -76,17 +87,10 @@
                new WorldGui( 400, 300 );
         }
   
-  if( usegui == true ) 
-        {
-               //don't close the window once time has finished
-               while( true )
-                 World::UpdateAll();
-        } 
-  else 
-        {
-               //close program once time has completed
-               bool quit = false;
-               while( quit == false )
-                 quit = World::UpdateAll();
-        }
+  if( usegui )
+        while( true ) World::UpdateAll();
+  else
+        while( ! World::UpdateAll() );
+
+  exit(0);
 }

Modified: code/stage/trunk/libstage/model_draw.cc
===================================================================
--- code/stage/trunk/libstage/model_draw.cc     2009-04-02 01:04:09 UTC (rev 
7570)
+++ code/stage/trunk/libstage/model_draw.cc     2009-04-02 23:50:59 UTC (rev 
7571)
@@ -247,15 +247,12 @@
 
 void Model::AddVisualizer( Visualizer* custom_visual, bool on_by_default )
 {
-       if( !custom_visual )
-               return;
-
-       //Visualizations can only be added to stage when run in a GUI
-       if( world_gui == NULL ) 
-         {
-                printf( "Unable to add custom visualization - it must be run 
with a GUI world\n" );
-                return;
-         }
+  if( !custom_visual )
+        return;
+  
+  // If there's no GUI, ignore this request
+  if( ! world_gui ) 
+        return;
        
        //save visual instance
        custom_visual_list = g_list_append(custom_visual_list, custom_visual );

Modified: code/stage/trunk/libstage/powerpack.cc
===================================================================
--- code/stage/trunk/libstage/powerpack.cc      2009-04-02 01:04:09 UTC (rev 
7570)
+++ code/stage/trunk/libstage/powerpack.cc      2009-04-02 23:50:59 UTC (rev 
7571)
@@ -228,7 +228,6 @@
 
   output_vis.AppendValue( amount );
   stored_vis.AppendValue( stored );
-  //stg_watts_t w = j / (interval / 1e6);
 }
 
 void PowerPack::Dissipate( stg_joules_t j, const Pose& p )

Modified: code/stage/trunk/worlds/simple.world
===================================================================
--- code/stage/trunk/worlds/simple.world        2009-04-02 01:04:09 UTC (rev 
7570)
+++ code/stage/trunk/worlds/simple.world        2009-04-02 23:50:59 UTC (rev 
7571)
@@ -9,6 +9,8 @@
 interval_sim 100  # simulation timestep in milliseconds
 interval_real 20  # real-time interval between simulation updates in 
milliseconds 
 
+quit_time 60
+
 paused 0
 
 resolution 0.02


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to