a13775aa603881141f838384f8e9042b224af05d
[shpub.git] / src / shpub / Command / Delete.php
1 <?php
2 namespace shpub;
3
4 class Command_Delete extends Command_AbstractProps
5 {
6     public static function opts(\Console_CommandLine $optParser)
7     {
8         $cmd = $optParser->addCommand('delete');
9         $cmd->addArgument(
10             'url',
11             [
12                 'optional'    => false,
13                 'description' => 'URL to remove',
14             ]
15         );
16     }
17
18     public function run(\Console_CommandLine_Result $cmdRes)
19     {
20         $url = Validator::url($cmdRes->args['url'], 'url');
21         if ($url === false) {
22             exit(10);
23         }
24
25         $req = new Request($this->cfg->host, $this->cfg);
26         $req->req->addPostParameter('action', 'delete');
27         $req->req->addPostParameter('url', $url);
28
29         $res = $req->send();
30         Log::info('Post deleted from server');
31     }
32 }
33 ?>