From: Christian Weiske Date: Tue, 13 Sep 2016 16:07:43 +0000 (+0200) Subject: add support for delete queries X-Git-Tag: v0.0.5~2 X-Git-Url: https://git.cweiske.de/shpub.git/commitdiff_plain/932bcd4bc95da51a819b099d284b7d25d4d50f05 add support for delete queries --- diff --git a/src/shpub/Cli.php b/src/shpub/Cli.php index eedbb10..e452f00 100644 --- a/src/shpub/Cli.php +++ b/src/shpub/Cli.php @@ -166,6 +166,8 @@ class Cli Command_Like::opts($optParser); Command_Repost::opts($optParser); + Command_Delete::opts($optParser); + return $optParser; } diff --git a/src/shpub/Command/Delete.php b/src/shpub/Command/Delete.php new file mode 100644 index 0000000..fec839f --- /dev/null +++ b/src/shpub/Command/Delete.php @@ -0,0 +1,43 @@ +cfg = $cfg; + } + + public static function opts(\Console_CommandLine $optParser) + { + $cmd = $optParser->addCommand('delete'); + $cmd->addArgument( + 'url', + [ + 'optional' => false, + 'description' => 'URL to remove', + ] + ); + } + + public function run(\Console_CommandLine_Result $cmdRes) + { + $url = Validator::url($cmdRes->args['url'], 'url'); + if ($url === false) { + exit(10); + } + + $req = new Request($this->cfg->host, $this->cfg); + $req->req->addPostParameter('action', 'delete'); + $req->req->addPostParameter('url', $url); + + $res = $req->send(); + Log::info('Post deleted from server'); + } +} +?>