add "published" option to notes
[shpub.git] / src / shpub / Command / Reply.php
index cb09ba77943e33231171523df6b73ca923b0f70b..622361a9d81f1aaa31b474e0088106a68ef5d2dd 100644 (file)
@@ -4,15 +4,34 @@ namespace shpub;
 class Command_Reply
 {
     /**
-     * @var Config_Host
+     * @var Config
      */
-    protected $host;
+    protected $cfg;
 
-    public function __construct($host)
+    public function __construct($cfg)
     {
-        $this->host = $host;
+        $this->cfg = $cfg;
     }
 
+    public static function opts(\Console_CommandLine $optParser)
+    {
+        $cmd = $optParser->addCommand('reply');
+        $cmd->addArgument(
+            'url',
+            [
+                'optional'    => false,
+                'description' => 'URL that is replied to',
+            ]
+        );
+        $cmd->addArgument(
+            'text',
+            [
+                'optional'    => false,
+                'multiple'    => true,
+                'description' => 'Reply text',
+            ]
+        );
+    }
     public function run($url, $text)
     {
         $url = Validator::url($url, 'url');
@@ -28,7 +47,7 @@ class Command_Reply
             ]
         );
 
-        $req = new Request($this->host);
+        $req = new Request($this->cfg->host, $this->cfg);
         $res = $req->send($body);
         $postUrl = $res->getHeader('Location');
         echo "Reply created at server\n";