X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/4e67ee4a6c7cc62f9c12f091660aae6b1e87d53b..059c6ab77b8e63210b9afc266d62c9f543d4d7ae:/src/shpub/Command/Note.php diff --git a/src/shpub/Command/Note.php b/src/shpub/Command/Note.php index a60422a..c7683f3 100644 --- a/src/shpub/Command/Note.php +++ b/src/shpub/Command/Note.php @@ -1,21 +1,12 @@ cfg = $cfg; - } - public static function opts(\Console_CommandLine $optParser) { $cmd = $optParser->addCommand('note'); + static::optsGeneric($cmd); $cmd->addArgument( 'text', [ @@ -26,20 +17,17 @@ class Command_Note ); } - public function run($command) + public function run(\Console_CommandLine_Result $cmdRes) { - $data = [ - 'h' => 'entry', - 'content' => $command->args['text'], - ]; - - $body = http_build_query($data); - $req = new Request($this->cfg->host, $this->cfg); - $res = $req->send($body); + $req->setType('entry'); + $req->addProperty('content', $cmdRes->args['text']); + $this->handleGenericOptions($cmdRes, $req); + + $res = $req->send(); $postUrl = $res->getHeader('Location'); - echo "Post created at server\n"; - echo $postUrl . "\n"; + Log::info('Post created at server'); + Log::msg($postUrl); } } ?>