From ff8573f63f912d05426b6928364146d1c7794f99 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 14 Sep 2016 21:31:08 +0200 Subject: [PATCH] add undelete command --- src/shpub/Cli.php | 1 + src/shpub/Command/Undelete.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/shpub/Command/Undelete.php diff --git a/src/shpub/Cli.php b/src/shpub/Cli.php index 75497eb..aa9dcaa 100644 --- a/src/shpub/Cli.php +++ b/src/shpub/Cli.php @@ -167,6 +167,7 @@ class Cli Command_Repost::opts($optParser); Command_Delete::opts($optParser); + Command_Undelete::opts($optParser); return $optParser; } diff --git a/src/shpub/Command/Undelete.php b/src/shpub/Command/Undelete.php new file mode 100644 index 0000000..ad3525f --- /dev/null +++ b/src/shpub/Command/Undelete.php @@ -0,0 +1,33 @@ +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'); + } +} +?> -- 2.30.2