debug option to print curl requests
[shpub.git] / src / shpub / Cli.php
index a57b287fda084518f5f47f2066105507be58a45b..62f824ee92546455cb309219983b63372d4f3ee1 100644 (file)
@@ -27,15 +27,27 @@ class Cli
                     $res->command->options['force']
                 );
                 break;
+
+            case 'server':
+                $cmd = new Command_Server($this->cfg);
+                $cmd->run($res->command->options['verbose']);
+                break;
+
             case 'like':
                 $this->requireValidHost();
-                $cmd = new Command_Like($this->cfg->host);
+                $cmd = new Command_Like($this->cfg);
                 $cmd->run($res->command->args['url']);
                 break;
-            case 'server':
-                $cmd = new Command_Server($this->cfg);
-                $cmd->run($res->command->options['verbose']);
+
+            case 'reply':
+                $this->requireValidHost();
+                $cmd = new Command_Reply($this->cfg);
+                $cmd->run(
+                    $res->command->args['url'],
+                    implode(' ', $res->command->args['text'])
+                );
                 break;
+
             default:
                 var_dump($this->cfg->host, $res);
                 Log::err('FIXME');
@@ -71,6 +83,7 @@ class Cli
             if ($opts['user'] !== null) {
                 $this->cfg->host->user = $opts['user'];
             }
+            $this->cfg->setDebug($opts['debug']);
 
             return $res;
         } catch (\Exception $exc) {
@@ -112,6 +125,16 @@ class Cli
                 'default'     => null,
             )
         );
+        $optParser->addOption(
+            'debug',
+            array(
+                'short_name'  => '-d',
+                'long_name'   => '--debug',
+                'description' => 'Verbose output',
+                'action'      => 'StoreTrue',
+                'default'     => false,
+            )
+        );
 
         $cmd = $optParser->addCommand('connect');
         $cmd->addOption(
@@ -134,7 +157,7 @@ class Cli
         $cmd->addArgument(
             'user',
             [
-                'optional'    => false,
+                'optional'    => true,
                 'description' => 'User URL',
             ]
         );
@@ -171,6 +194,7 @@ class Cli
             'text',
             [
                 'optional'    => false,
+                'multiple'    => true,
                 'description' => 'Reply text',
             ]
         );