Add bookmark command
[shpub.git] / src / shpub / Command / Undelete.php
1 <?php
2 namespace shpub;
3
4 class Command_Undelete extends Command_AbstractProps
5 {
6     public static function opts(\Console_CommandLine $optParser)
7     {
8         $cmd = $optParser->addCommand('undelete');
9         $cmd->addArgument(
10             'url',
11             [
12                 'optional'    => false,
13                 'description' => 'URL to restore',
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', 'undelete');
27         $req->req->addPostParameter('url', $url);
28
29         $res = $req->send();
30         Log::info('Post restored at server');
31     }
32 }
33 ?>