1694243ef9cb3fa534900bffadb4b713d20c77c6
[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         static::addOptHtml($cmd);
10         static::optsGeneric($cmd);
11         $cmd->addArgument(
12             'text',
13             [
14                 'optional'    => false,
15                 'multiple'    => false,
16                 'description' => 'Post text',
17             ]
18         );
19     }
20
21     public function run(\Console_CommandLine_Result $cmdRes)
22     {
23         $req = new Request($this->cfg->host, $this->cfg);
24         $req->setType('entry');
25         $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
26         $this->handleGenericOptions($cmdRes, $req);
27
28         $res = $req->send();
29         $postUrl = $res->getHeader('Location');
30         Log::info('Post created at server');
31         Log::msg($postUrl);
32     }
33 }
34 ?>