make the request observer work correctly, remove response logging in main class
[linksys-wrt3g-tools.git] / scripts / linksys-wrt3g.php
index 824c287ae8861718b8f2945de4fa10068aef9893..219e081c1c87be924830d8e756b32e1c4a622dac 100755 (executable)
@@ -27,10 +27,7 @@ if (file_exists($configFile)) {
 }
 
 $parser = new Console_CommandLine();
-$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->description = "Tool to control Linksys WRT3g routers";
 $parser->version = '0.0.1';//FIXME: dynamic
 $parser->addOption(
     'host',
@@ -78,7 +75,8 @@ $parser->addOption(
     'dummy',
     array(
         'long_name'   => '--dummy',
-        'description' => 'Use dummy router data, not real ones',
+        'description' => "Use dummy router data, not real ones.
+Dummy responses can be controlled with the host parameter; 3-letter numeric hosts are interpreted as HTTP response code",
         'action'      => 'StoreTrue',
     )
 );
@@ -91,16 +89,16 @@ $stCmd = $parser->addCommand(
     )
 );
 $stCmd = $parser->addCommand(
-    'cardstatus',
+    'card',
     array(
-        'aliases'     => array('c', 'cs'),
-        'description' => 'Show the card/SIM status'
+        'aliases'     => array('c'),
+        'description' => 'Show the PC card/SIM status'
     )
 );
 $stCmd = $parser->addCommand(
-    'allstatus',
+    'all',
     array(
-        'aliases'     => array('a', 'as'),
+        'aliases'     => array('a'),
         'description' => 'Show all status details'
     )
 );
@@ -123,16 +121,16 @@ try {
 
 try {
     $router = new Wrt3g();
+    $router->verbosity = $result->options['verbosity'];
+    $router->host      = $result->options['host'];
+    $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);
-    } else {
     }
-    $router->verbosity = $result->options['verbosity'];
-    $router->host      = $result->options['host'];
-    $router->user      = $result->options['user'];
-    $router->password  = $result->options['password'];
 
     $router->log('Command: ' . $result->command_name, 2);
 
@@ -145,13 +143,13 @@ try {
         }
         break;
 
-    case 'allstatus':
-    case 'cardstatus':
+    case 'all':
+    case 'card':
     case 'status':
     default:
-        if ($result->command_name == 'allstatus') {
+        if ($result->command_name == 'all') {
             $arStatus = $router->getFullStatus();
-        } else if ($result->command_name == 'cardstatus') {
+        } else if ($result->command_name == 'card') {
             $arStatus = $router->getCardStatus();
         } else {
             $arStatus = $router->getConnectionStatus();