add description for all commands
[shpub.git] / src / shpub / Command / Article.php
1 <?php
2 namespace shpub;
3
4 class Command_Article extends Command_AbstractProps
5 {
6     public static function opts(\Console_CommandLine $optParser)
7     {
8         $cmd = $optParser->addCommand('article');
9         $cmd->description = 'Create an article';
10         static::addOptHtml($cmd);
11         static::optsGeneric($cmd);
12         $cmd->addArgument(
13             'title',
14             [
15                 'optional'    => false,
16                 'multiple'    => false,
17                 'description' => 'Title/Name',
18             ]
19         );
20         $cmd->addArgument(
21             'text',
22             [
23                 'optional'    => false,
24                 'multiple'    => false,
25                 'description' => 'Text content',
26             ]
27         );
28     }
29
30     public function run(\Console_CommandLine_Result $cmdRes)
31     {
32         $req = new Request($this->cfg->host, $this->cfg);
33         $req->setType('entry');
34         $req->addProperty('name', $cmdRes->args['title']);
35         $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
36         $this->handleGenericOptions($cmdRes, $req);
37
38         $res = $req->send();
39         $postUrl = $res->getHeader('Location');
40         Log::info('Article created at server');
41         Log::msg($postUrl);
42     }
43 }
44 ?>