X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/381a979bd441d8ffbed46807c9f5598987093a49..059c6ab77b8e63210b9afc266d62c9f543d4d7ae:/src/shpub/Command/AbstractProps.php diff --git a/src/shpub/Command/AbstractProps.php b/src/shpub/Command/AbstractProps.php index 0184c10..c9ea8bb 100644 --- a/src/shpub/Command/AbstractProps.php +++ b/src/shpub/Command/AbstractProps.php @@ -33,7 +33,7 @@ class Command_AbstractProps 'files', array( 'short_name' => '-f', - 'long_name' => '--files', + 'long_name' => '--file', 'description' => 'Files or URLs to upload', 'help_name' => 'PATH', 'action' => 'StoreArray', @@ -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 ) {