Add "json" option
[shpub.git] / src / shpub / Command / Delete.php
index fec839f..7735e21 100644 (file)
@@ -3,19 +3,10 @@ namespace shpub;
 
 class Command_Delete extends Command_AbstractProps
 {
-    /**
-     * @var Config
-     */
-    protected $cfg;
-
-    public function __construct($cfg)
-    {
-        $this->cfg = $cfg;
-    }
-
     public static function opts(\Console_CommandLine $optParser)
     {
         $cmd = $optParser->addCommand('delete');
+        static::addOptJson($cmd);
         $cmd->addArgument(
             'url',
             [
@@ -33,8 +24,9 @@ class Command_Delete extends Command_AbstractProps
         }
 
         $req = new Request($this->cfg->host, $this->cfg);
-        $req->req->addPostParameter('action', 'delete');
-        $req->req->addPostParameter('url', $url);
+        $this->handleOptJson($cmdRes, $req);
+        $req->setAction('delete');
+        $req->setUrl($url);
 
         $res = $req->send();
         Log::info('Post deleted from server');