add undelete command
[shpub.git] / src / shpub / Command / Undelete.php
diff --git a/src/shpub/Command/Undelete.php b/src/shpub/Command/Undelete.php
new file mode 100644 (file)
index 0000000..ad3525f
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+namespace shpub;
+
+class Command_Undelete extends Command_AbstractProps
+{
+    public static function opts(\Console_CommandLine $optParser)
+    {
+        $cmd = $optParser->addCommand('undelete');
+        $cmd->addArgument(
+            'url',
+            [
+                'optional'    => false,
+                'description' => 'URL to restore',
+            ]
+        );
+    }
+
+    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', 'undelete');
+        $req->req->addPostParameter('url', $url);
+
+        $res = $req->send();
+        Log::info('Post restored at server');
+    }
+}
+?>