From: Christian Weiske Date: Mon, 12 Sep 2016 04:46:02 +0000 (+0200) Subject: add support for generic additional properties X-Git-Tag: v0.0.5~8 X-Git-Url: https://git.cweiske.de/shpub.git/commitdiff_plain/5c5fff50b8e88170cbf6cb51a8158af7caa00b10 add support for generic additional properties --- diff --git a/src/shpub/Command/Note.php b/src/shpub/Command/Note.php index aceffcf..6fb7cec 100644 --- a/src/shpub/Command/Note.php +++ b/src/shpub/Command/Note.php @@ -48,6 +48,17 @@ class Command_Note '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', [ @@ -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"; diff --git a/src/shpub/Request.php b/src/shpub/Request.php index 44894c5..edca12a 100644 --- a/src/shpub/Request.php +++ b/src/shpub/Request.php @@ -68,7 +68,15 @@ class Request 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) {