Release 0.7.1
[shpub.git] / src / shpub / Command / Note.php
1 <?php
2 namespace shpub;
3
4 class Command_Note extends Command_AbstractProps
5 {
6     public static function opts(\Console_CommandLine $optParser)
7     {
8         $cmd = $optParser->addCommand('note');
9         $cmd->description = 'Create a note';
10         static::addOptHtml($cmd);
11         static::optsGeneric($cmd);
12         $cmd->addArgument(
13             'text',
14             [
15                 'optional'    => false,
16                 'multiple'    => false,
17                 'description' => 'Post text',
18             ]
19         );
20     }
21
22     public function run(\Console_CommandLine_Result $cmdRes)
23     {
24         $req = new Request($this->cfg->host, $this->cfg);
25         $req->setType('entry');
26         $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
27         $this->handleGenericOptions($cmdRes, $req);
28
29         $res = $req->send();
30         $postUrl = $res->getHeader('Location');
31         Log::info('Post created at server');
32         Log::msg($postUrl);
33     }
34 }
35 ?>