add support for generic additional properties
authorChristian Weiske <cweiske@cweiske.de>
Mon, 12 Sep 2016 04:46:02 +0000 (06:46 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 12 Sep 2016 04:46:02 +0000 (06:46 +0200)
src/shpub/Command/Note.php
src/shpub/Request.php

index aceffcfb1e6ffc34cc46c6a74879d8f96db3230d..6fb7ceca34d0def575b79756ee9a7e3e1f369d4d 100644 (file)
@@ -48,6 +48,17 @@ class Command_Note
                 'default'     => null,
             )
         );
                 'default'     => null,
             )
         );
+        $cmd->addOption(
+            'x',
+            array(
+                'short_name'  => '-x',
+                'long_name'   => '--xprop',
+                'description' => 'Additional property',
+                'help_name'   => 'key=value',
+                'action'      => 'StoreArray',
+                'default'     => [],
+            )
+        );
         $cmd->addArgument(
             'text',
             [
         $cmd->addArgument(
             'text',
             [
@@ -132,6 +143,13 @@ class Command_Note
             }
         }
 
             }
         }
 
+        if (count($command->options['x'])) {
+            foreach ($command->options['x'] as $xproperty) {
+                list($propkey, $propval) = explode('=', $xproperty, 2);
+                $req->req->addPostParameter($propkey, $propval);
+            }
+        }
+
         $res = $req->send();
         $postUrl = $res->getHeader('Location');
         echo "Post created at server\n";
         $res = $req->send();
         $postUrl = $res->getHeader('Location');
         echo "Post created at server\n";
index 44894c572124a5662042145855eb7d9283129520..edca12aae84749c8d71b57cd462bbd251d797b2b 100644 (file)
@@ -68,7 +68,15 @@ class Request
 
         if (count($this->uploadsInfo) == 0) {
             foreach ($postParams as $k => $v) {
 
         if (count($this->uploadsInfo) == 0) {
             foreach ($postParams as $k => $v) {
-                $command .= ' -d ' . escapeshellarg($k . '=' . $v);
+                if (!is_array($v)) {
+                    $command .= ' -d ' . escapeshellarg($k . '=' . $v);
+                } else {
+                    foreach ($v as $ak => $av) {
+                        $command .= ' -d ' . escapeshellarg(
+                            $k . '[' . $ak . ']=' . $av
+                        );
+                    }
+                }
             }
         } else {
             foreach ($postParams as $k => $v) {
             }
         } else {
             foreach ($postParams as $k => $v) {