fix dummy setup
[linksys-wrt3g-tools.git] / scripts / linksys-wrt3g.php
index 7d87cd1decf30104be0ec3728cc7745c71b0bd39..628dfe97f68e30bb1b7e1ba3b723766b17c30570 100755 (executable)
@@ -27,7 +27,10 @@ if (file_exists($configFile)) {
 }
 
 $parser = new Console_CommandLine();
 }
 
 $parser = new Console_CommandLine();
-$parser->description = 'Tool to control Linksys WRT3g routers';
+$parser->description = "Tool to control Linksys WRT3g routers
+
+Dummy responses can be controlled with the host parameter:
+ A 3-letter numeric host is interpreted as HTTP response code";
 $parser->version = '0.0.1';//FIXME: dynamic
 $parser->addOption(
     'host',
 $parser->version = '0.0.1';//FIXME: dynamic
 $parser->addOption(
     'host',
@@ -71,6 +74,14 @@ $parser->addOption(
         'action'      => 'Counter',
     )
 );
         'action'      => 'Counter',
     )
 );
+$parser->addOption(
+    'dummy',
+    array(
+        'long_name'   => '--dummy',
+        'description' => 'Use dummy router data, not real ones',
+        'action'      => 'StoreTrue',
+    )
+);
 
 $stCmd = $parser->addCommand(
     'status',
 
 $stCmd = $parser->addCommand(
     'status',
@@ -117,6 +128,12 @@ try {
     $router->user      = $result->options['user'];
     $router->password  = $result->options['password'];
 
     $router->user      = $result->options['user'];
     $router->password  = $result->options['password'];
 
+    if ($result->options['dummy']) {
+        require_once 'Wrt3g/DummyRequest.php';
+        $router->requestClass = 'Wrt3g_DummyRequest';
+        $router->log('Using dummy data', 1);
+    }
+
     $router->log('Command: ' . $result->command_name, 2);
 
     switch ($result->command_name) {
     $router->log('Command: ' . $result->command_name, 2);
 
     switch ($result->command_name) {
@@ -140,7 +157,13 @@ try {
             $arStatus = $router->getConnectionStatus();
         }
         foreach ($arStatus as $key => $value) {
             $arStatus = $router->getConnectionStatus();
         }
         foreach ($arStatus as $key => $value) {
-            echo $key . ': ' . $value . "\n";
+            echo $key . ': ';
+            if (is_array($value)) {
+                //session usage
+                echo var_export($value, true) . "\n";
+            } else {
+                echo $value . "\n";
+            }
         }
     }
 } catch (Exception $e) {
         }
     }
 } catch (Exception $e) {