<?php
namespace shpub;
-class Command_Note
+class Command_Note extends Command_AbstractProps
{
- /**
- * @var Config
- */
- protected $cfg;
-
- public function __construct($cfg)
- {
- $this->cfg = $cfg;
- }
-
public static function opts(\Console_CommandLine $optParser)
{
$cmd = $optParser->addCommand('note');
+ $cmd->description = 'Create a note';
+ static::addOptHtml($cmd);
+ static::optsGeneric($cmd);
$cmd->addArgument(
'text',
[
);
}
- 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->addContent($cmdRes->args['text'], $cmdRes->options['html']);
+ $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);
}
}
?>