X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/a5b93d3ad9c111fac520c1e5a887d4eac43f19b0..059c6ab77b8e63210b9afc266d62c9f543d4d7ae:/src/shpub/Command/AbstractProps.php diff --git a/src/shpub/Command/AbstractProps.php b/src/shpub/Command/AbstractProps.php index 822fc77..c9ea8bb 100644 --- a/src/shpub/Command/AbstractProps.php +++ b/src/shpub/Command/AbstractProps.php @@ -104,11 +104,27 @@ class Command_AbstractProps 'default' => [], ) ); + static::addOptJson($cmd); + } + + protected static function addOptJson(\Console_CommandLine_Command $cmd) + { + $cmd->addOption( + 'json', + array( + 'long_name' => '--json', + 'description' => 'Send request data as JSON', + 'action' => 'StoreTrue', + 'default' => false, + ) + ); } protected function handleGenericOptions( \Console_CommandLine_Result $cmdRes, Request $req ) { + $this->handleOptJson($cmdRes, $req); + if ($cmdRes->options['published'] !== null) { $req->req->addPostParameter( 'published', $cmdRes->options['published'] @@ -146,7 +162,7 @@ class Command_AbstractProps $postParams = []; foreach ($cmdRes->options['x'] as $xproperty) { list($propkey, $propval) = explode('=', $xproperty, 2); - if (!isset($postParams[$propkey] )) { + if (!isset($postParams[$propkey])) { $postParams[$propkey] = []; } $postParams[$propkey][] = $propval; @@ -157,6 +173,12 @@ class Command_AbstractProps } } + protected function handleOptJson( + \Console_CommandLine_Result $cmdRes, Request $req + ) { + $req->setSendAsJson($cmdRes->options['json']); + } + protected function handleFiles( \Console_CommandLine_Result $cmdRes, Request $req ) {