add description for all commands
[shpub.git] / src / shpub / Command / Article.php
index b51740de1487674143128fa52958e0f241ca2670..018b4034f75d9dfa25205c767edd251a884912b1 100644 (file)
@@ -3,29 +3,11 @@ namespace shpub;
 
 class Command_Article extends Command_AbstractProps
 {
-    /**
-     * @var Config
-     */
-    protected $cfg;
-
-    public function __construct($cfg)
-    {
-        $this->cfg = $cfg;
-    }
-
     public static function opts(\Console_CommandLine $optParser)
     {
         $cmd = $optParser->addCommand('article');
-        $cmd->addOption(
-            'html',
-            array(
-                'short_name'  => '-h',
-                'long_name'   => '--html',
-                'description' => 'Text content is HTML',
-                'action'      => 'StoreTrue',
-                'default'     => false,
-            )
-        );
+        $cmd->description = 'Create an article';
+        static::addOptHtml($cmd);
         static::optsGeneric($cmd);
         $cmd->addArgument(
             'title',
@@ -48,15 +30,9 @@ class Command_Article extends Command_AbstractProps
     public function run(\Console_CommandLine_Result $cmdRes)
     {
         $req = new Request($this->cfg->host, $this->cfg);
-        $req->req->addPostParameter('h', 'entry');
-        $req->req->addPostParameter('name', $cmdRes->args['title']);
-        if ($cmdRes->options['html']) {
-            $req->req->addPostParameter(
-                'content[html]', $cmdRes->args['text']
-            );
-        } else {
-            $req->req->addPostParameter('content', $cmdRes->args['text']);
-        }
+        $req->setType('entry');
+        $req->addProperty('name', $cmdRes->args['title']);
+        $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
         $this->handleGenericOptions($cmdRes, $req);
 
         $res = $req->send();