move generic options into separate class
[shpub.git] / src / shpub / Command / Note.php
index a60422aad16479498883b2d7b79523aaeaa9b250..de6794890711f4d73fd9354c7583ff06370a683e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace shpub;
 
-class Command_Note
+class Command_Note extends Command_AbstractProps
 {
     /**
      * @var Config
@@ -16,6 +16,7 @@ class Command_Note
     public static function opts(\Console_CommandLine $optParser)
     {
         $cmd = $optParser->addCommand('note');
+        static::optsGeneric($cmd);
         $cmd->addArgument(
             'text',
             [
@@ -26,17 +27,14 @@ class Command_Note
         );
     }
 
-    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->req->addPostParameter('h', 'entry');
+        $req->req->addPostParameter('content', $cmdRes->args['text']);
+        $this->handleGenericOptions($cmdRes, $req);
+
+        $res = $req->send();
         $postUrl = $res->getHeader('Location');
         echo "Post created at server\n";
         echo $postUrl . "\n";