Hello community, here is the log from the commit of package platformsh-cli for openSUSE:Factory checked in at 2018-03-22 12:05:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/platformsh-cli (Old) and /work/SRC/openSUSE:Factory/.platformsh-cli.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "platformsh-cli" Thu Mar 22 12:05:23 2018 rev:39 rq:589405 version:3.31.0 Changes: -------- --- /work/SRC/openSUSE:Factory/platformsh-cli/platformsh-cli.changes 2018-03-02 21:12:28.371290861 +0100 +++ /work/SRC/openSUSE:Factory/.platformsh-cli.new/platformsh-cli.changes 2018-03-22 12:10:50.285369972 +0100 @@ -1,0 +2,51 @@ +Tue Mar 20 22:34:15 UTC 2018 - ji...@boombatower.com + +- Update to version 3.31.0: + * Release v3.31.0 + * Fix bug: boolean false fields omitted when creating integrations + * Re-implement line wrapping to account for trimming + * [multi] Accept URLs as project identifiers + * Formatted text improvements + * Fix wrapping of indented cells + * Wrap cell contents while preserving decoration + * Display username in already-logged-in message + * [build] Run post_deploy hooks if --run-deploy-hooks option is used + * Add project:clear-build-cache command + * Less wordy + * Fix requiring environment when level not specified + * Add short variable level option, e.g. '-l p' + * Recommend other variable commands + * Removing duplicate message + * Fix prefixing + * Add <name> argument to variable:create + * Clean up and pass on wait options + * Handle variables at both levels + * Update README command list + * Mark some variable commands as deprecated + * Add --enabled option for variable:create and variable:update + * Display variables on create or update + * Add --property option to variable:get + * Add variable:list command + * Modify variable:get so it works with project or environment level variables + * Add variable:update command + * Add variable:create command + * Update API client: avoid loading individual activiites when description property is missing + * Fix wrapping of text decoration in adaptive table + * Un-hide some commands + * [auth:browser-login] Expand port range; add detailed port error message; simplify port validation + * [subscription:info] Update command description + * [list] Add --all option to show hidden commands + * Trim whitespace from API error messages + * Limit the amount of projects that can trigger a project choice + * Release v3.30.1 + * [environment:push] Fix inverse --no-wait/--wait logic + * Allow overriding the last version and release branch in self:release [skip changelog] + * Always use the deployment API for the app list + * [self:release] Update changelog automatically if release-changelog is out of date [skip changelog] + * [environment:push] Fix inverse --no-wait/--wait logic + * Allow overriding the last version and release branch in self:release [skip changelog] + * Always interact where possible to ask for the project / environment (#690) + * Always use the deployment API for the app list + * [self:release] Update changelog automatically if release-changelog is out of date [skip changelog] + +------------------------------------------------------------------- Old: ---- platformsh-cli-3.30.0.tar.xz New: ---- platformsh-cli-3.31.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ platformsh-cli.spec ++++++ --- /var/tmp/diff_new_pack.eQOc6v/_old 2018-03-22 12:10:51.297333700 +0100 +++ /var/tmp/diff_new_pack.eQOc6v/_new 2018-03-22 12:10:51.325332697 +0100 @@ -17,7 +17,7 @@ Name: platformsh-cli -Version: 3.30.0 +Version: 3.31.0 Release: 0 Summary: Tool for managing Platform.sh services from the command line # See licenses.txt for dependency licenses. ++++++ _service ++++++ --- /var/tmp/diff_new_pack.eQOc6v/_old 2018-03-22 12:10:51.409329686 +0100 +++ /var/tmp/diff_new_pack.eQOc6v/_new 2018-03-22 12:10:51.413329543 +0100 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="disabled"> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">refs/tags/v3.30.0</param> + <param name="revision">refs/tags/v3.31.0</param> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.eQOc6v/_old 2018-03-22 12:10:51.445328396 +0100 +++ /var/tmp/diff_new_pack.eQOc6v/_new 2018-03-22 12:10:51.449328253 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> - <param name="changesrevision">5090df77d2e6441e25c5dc01c37f323e0f5f5dc7</param> + <param name="changesrevision">d57ebed7395b7b70104b8d06c3be4c42d0c4c987</param> </service> </servicedata> ++++++ licenses.txt ++++++ --- /var/tmp/diff_new_pack.eQOc6v/_old 2018-03-22 12:10:51.501326389 +0100 +++ /var/tmp/diff_new_pack.eQOc6v/_new 2018-03-22 12:10:51.505326245 +0100 @@ -17,8 +17,8 @@ padraic/humbug_get_contents 1.1.2 BSD-3-Clause padraic/phar-updater v1.0.5 BSD-3-Clause paragonie/random_compat v2.0.11 MIT -platformsh/client v0.16.2 MIT -platformsh/console-form v0.0.16 MIT +platformsh/client v0.17.1 MIT +platformsh/console-form v0.0.20 MIT psr/container 1.0.0 MIT psr/log 1.0.2 MIT react/promise v2.5.1 MIT ++++++ platformsh-cli-3.30.0.tar.xz -> platformsh-cli-3.31.0.tar.xz ++++++ ++++ 2423 lines of diff (skipped) ++++++ platformsh-cli-vendor.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/autoload.php new/vendor/autoload.php --- old/vendor/autoload.php 2018-03-02 02:34:43.143555839 +0100 +++ new/vendor/autoload.php 2018-03-20 23:34:19.995913199 +0100 @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit3cffc5631be129fcb36d114cc9a40b12::getLoader(); +return ComposerAutoloaderInitee1b8b794f0ceb50ba83ef4d323343e3::getLoader(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_real.php new/vendor/composer/autoload_real.php --- old/vendor/composer/autoload_real.php 2018-03-02 02:34:43.143555839 +0100 +++ new/vendor/composer/autoload_real.php 2018-03-20 23:34:19.995913199 +0100 @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit3cffc5631be129fcb36d114cc9a40b12 +class ComposerAutoloaderInitee1b8b794f0ceb50ba83ef4d323343e3 { private static $loader; @@ -19,15 +19,15 @@ return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit3cffc5631be129fcb36d114cc9a40b12', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitee1b8b794f0ceb50ba83ef4d323343e3', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit3cffc5631be129fcb36d114cc9a40b12', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitee1b8b794f0ceb50ba83ef4d323343e3', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit3cffc5631be129fcb36d114cc9a40b12::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitee1b8b794f0ceb50ba83ef4d323343e3::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit3cffc5631be129fcb36d114cc9a40b12::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitee1b8b794f0ceb50ba83ef4d323343e3::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire3cffc5631be129fcb36d114cc9a40b12($fileIdentifier, $file); + composerRequireee1b8b794f0ceb50ba83ef4d323343e3($fileIdentifier, $file); } return $loader; } } -function composerRequire3cffc5631be129fcb36d114cc9a40b12($fileIdentifier, $file) +function composerRequireee1b8b794f0ceb50ba83ef4d323343e3($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_static.php new/vendor/composer/autoload_static.php --- old/vendor/composer/autoload_static.php 2018-03-02 02:34:43.143555839 +0100 +++ new/vendor/composer/autoload_static.php 2018-03-20 23:34:19.995913199 +0100 @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit3cffc5631be129fcb36d114cc9a40b12 +class ComposerStaticInitee1b8b794f0ceb50ba83ef4d323343e3 { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', @@ -195,9 +195,9 @@ public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit3cffc5631be129fcb36d114cc9a40b12::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit3cffc5631be129fcb36d114cc9a40b12::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit3cffc5631be129fcb36d114cc9a40b12::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitee1b8b794f0ceb50ba83ef4d323343e3::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitee1b8b794f0ceb50ba83ef4d323343e3::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitee1b8b794f0ceb50ba83ef4d323343e3::$classMap; }, null, ClassLoader::class); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/installed.json new/vendor/composer/installed.json --- old/vendor/composer/installed.json 2018-03-02 02:34:42.195545857 +0100 +++ new/vendor/composer/installed.json 2018-03-20 23:34:19.399907951 +0100 @@ -778,17 +778,17 @@ }, { "name": "platformsh/client", - "version": "v0.16.2", - "version_normalized": "0.16.2.0", + "version": "v0.17.1", + "version_normalized": "0.17.1.0", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "d148ca8d4c3239ada8441515a4d8a02067037c96" + "reference": "37d986f5909fbdd80c57b1765670607c9b36373f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/d148ca8d4c3239ada8441515a4d8a02067037c96", - "reference": "d148ca8d4c3239ada8441515a4d8a02067037c96", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/37d986f5909fbdd80c57b1765670607c9b36373f", + "reference": "37d986f5909fbdd80c57b1765670607c9b36373f", "shasum": "" }, "require": { @@ -801,7 +801,7 @@ "require-dev": { "phpunit/phpunit": "~4.5" }, - "time": "2018-03-01T00:18:35+00:00", + "time": "2018-03-15T16:06:08+00:00", "type": "library", "extra": { "patches": { @@ -1068,17 +1068,17 @@ }, { "name": "platformsh/console-form", - "version": "v0.0.16", - "version_normalized": "0.0.16.0", + "version": "v0.0.20", + "version_normalized": "0.0.20.0", "source": { "type": "git", "url": "https://github.com/platformsh/console-form.git", - "reference": "57931bde54bcc13ae0c784a71b41bcf32f1adeba" + "reference": "8fb1a45fb3acb05826a411dddd45c7b86def80f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/console-form/zipball/57931bde54bcc13ae0c784a71b41bcf32f1adeba", - "reference": "57931bde54bcc13ae0c784a71b41bcf32f1adeba", + "url": "https://api.github.com/repos/platformsh/console-form/zipball/8fb1a45fb3acb05826a411dddd45c7b86def80f3", + "reference": "8fb1a45fb3acb05826a411dddd45c7b86def80f3", "shasum": "" }, "require": { @@ -1088,7 +1088,7 @@ "require-dev": { "phpunit/phpunit": "^5.0" }, - "time": "2018-02-12T11:15:24+00:00", + "time": "2018-03-20T19:18:47+00:00", "type": "library", "installation-source": "dist", "autoload": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Activity.php new/vendor/platformsh/client/src/Model/Activity.php --- old/vendor/platformsh/client/src/Model/Activity.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Activity.php 2018-03-15 17:06:08.000000000 +0100 @@ -23,6 +23,7 @@ * @property-read string $result * @property-read string $started_at * @property-read string $type + * @property-read string $description The HTML description of the activity. * @property-read array $payload */ class Activity extends Resource @@ -130,7 +131,7 @@ */ public function getDescription($html = false) { - if ($this->hasProperty('description')) { + if ($this->hasProperty('description', false)) { $description = $this->getProperty('description'); return $html ? $description : strip_tags($description); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Environment.php new/vendor/platformsh/client/src/Model/Environment.php --- old/vendor/platformsh/client/src/Model/Environment.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Environment.php 2018-03-15 17:06:08.000000000 +0100 @@ -103,11 +103,9 @@ /** * Get the SSH URL via the legacy 'ssh' link. * - * @param string $app - * * @return string */ - private function constructLegacySshUrl($app) + private function constructLegacySshUrl() { if (!$this->hasLink('ssh')) { $id = $this->data['id']; @@ -117,9 +115,7 @@ throw new OperationUnavailableException("No SSH URL found for environment '$id'. You may not have permission to SSH."); } - $suffix = $app ? '--' . $app : ''; - - return $this->convertSshUrl($this->getLink('ssh'), $suffix); + return $this->convertSshUrl($this->getLink('ssh')); } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Project.php new/vendor/platformsh/client/src/Model/Project.php --- old/vendor/platformsh/client/src/Model/Project.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Project.php 2018-03-15 17:06:08.000000000 +0100 @@ -135,6 +135,18 @@ } /** + * @inheritdoc + */ + public function operationAvailable($op) + { + if (!parent::operationAvailable($op)) { + $this->ensureFull(); + } + + return parent::operationAvailable($op); + } + + /** * Get a list of environments for the project. * * @param int $limit @@ -394,4 +406,14 @@ throw new \RuntimeException('Failed to find project ID from URL: ' . $url); } + + /** + * Clear the project's build cache. + * + * @return Result + */ + public function clearBuildCache() + { + return $this->runOperation('clear-build-cache'); + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Resource.php new/vendor/platformsh/client/src/Model/Resource.php --- old/vendor/platformsh/client/src/Model/Resource.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Resource.php 2018-03-15 17:06:08.000000000 +0100 @@ -350,7 +350,7 @@ * @param string $method * @param array $body * - * @return array + * @return Result */ protected function runOperation($op, $method = 'post', array $body = []) { @@ -363,8 +363,9 @@ } $request = $this->client ->createRequest($method, $this->getLink("#$op"), $options); + $data = $this->send($request, $this->client); - return $this->send($request, $this->client); + return new Result($data, $this->baseUrl, $this->client, get_called_class()); } /** @@ -378,8 +379,7 @@ */ protected function runLongOperation($op, $method = 'post', array $body = []) { - $data = $this->runOperation($op, $method, $body); - $result = new Result($data, $this->baseUrl, $this->client, get_called_class()); + $result = $this->runOperation($op, $method, $body); $activities = $result->getActivities(); if (count($activities) !== 1) { trigger_error(sprintf("Expected one activity, found %d", count($activities)), E_USER_WARNING); @@ -461,11 +461,9 @@ $message = "Cannot update resource due to validation error(s): " . implode('; ', $errors); throw new \InvalidArgumentException($message); } - $data = $this->runOperation('edit', 'patch', $values); - + $data = $this->runOperation('edit', 'patch', $values)->getData(); if (isset($data['_embedded']['entity'])) { - $resourceData = $data['_embedded']['entity']; - $this->setData($resourceData); + $this->setData($data['_embedded']['entity']); $this->isFull = true; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Result.php new/vendor/platformsh/client/src/Model/Result.php --- old/vendor/platformsh/client/src/Model/Result.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Result.php 2018-03-15 17:06:08.000000000 +0100 @@ -18,7 +18,7 @@ */ public function __construct(array $data, $baseUrl, ClientInterface $client, $className) { - parent::__construct($data, $baseUrl, $client); + parent::__construct($data, $baseUrl, $client, true); $this->setResourceClass($className); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Subscription.php new/vendor/platformsh/client/src/Model/Subscription.php --- old/vendor/platformsh/client/src/Model/Subscription.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Subscription.php 2018-03-15 17:06:08.000000000 +0100 @@ -37,6 +37,10 @@ /** * {@inheritdoc} * + * @internal Use PlatformClient::createSubscription() to create a new subscription. + * + * @see \Platformsh\Client\PlatformClient::createSubscription() + * * @return static */ public static function create(array $body, $collectionUrl, ClientInterface $client) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Variable.php new/vendor/platformsh/client/src/Model/Variable.php --- old/vendor/platformsh/client/src/Model/Variable.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Variable.php 2018-03-15 17:06:08.000000000 +0100 @@ -15,6 +15,9 @@ * The name of the variable. * @property-read string $value * The value of the variable. + * @property-read bool $is_sensitive + * Whether the variable is sensitive. If so, it will not be copied to child + * environments, and its value will not be returned in the API. * @property-read bool $is_enabled * Whether the variable is enabled. * @property-read bool $is_json @@ -25,6 +28,8 @@ * The time the variable was last updated (ISO 8601). * @property-read bool $inherited * Whether the variable was inherited from a parent environment. + * @property-read bool $is_inheritable + * Whether the variable is allowed to be inherited by a child environment. */ class Variable extends Resource { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/PlatformClient.php new/vendor/platformsh/client/src/PlatformClient.php --- old/vendor/platformsh/client/src/PlatformClient.php 2018-03-01 01:18:35.000000000 +0100 +++ new/vendor/platformsh/client/src/PlatformClient.php 2018-03-15 17:06:08.000000000 +0100 @@ -232,9 +232,13 @@ * @param int $environments The number of available environments. * @param array $activationCallback An activation callback for the subscription. * - * @see PlatformClient::getRegions(). + * @see PlatformClient::getRegions() + * @see Subscription::wait() * * @return Subscription + * A subscription, representing a project. Use Subscription::wait() or + * similar code to wait for the subscription's project to be provisioned + * and activated. */ public function createSubscription($region, $plan = 'development', $title = null, $storage = null, $environments = null, array $activationCallback = null) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/ArrayField.php new/vendor/platformsh/console-form/src/Field/ArrayField.php --- old/vendor/platformsh/console-form/src/Field/ArrayField.php 2018-02-12 12:15:24.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/ArrayField.php 2018-03-20 20:18:47.000000000 +0100 @@ -62,6 +62,10 @@ */ public function matchesCondition($userValue, $condition) { + if (is_callable($condition)) { + return $condition($userValue); + } + return !array_diff($userValue, $condition); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/BooleanField.php new/vendor/platformsh/console-form/src/Field/BooleanField.php --- old/vendor/platformsh/console-form/src/Field/BooleanField.php 2018-02-12 12:15:24.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/BooleanField.php 2018-03-20 20:18:47.000000000 +0100 @@ -22,6 +22,19 @@ /** * {@inheritdoc} */ + public function isEmpty($value) + { + // False is not empty. + if ($value === false) { + return false; + } + + return parent::isEmpty($value); + } + + /** + * {@inheritdoc} + */ protected function normalize($value) { if (is_bool($value)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/Field.php new/vendor/platformsh/console-form/src/Field/Field.php --- old/vendor/platformsh/console-form/src/Field/Field.php 2018-02-12 12:15:24.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/Field.php 2018-03-20 20:18:47.000000000 +0100 @@ -18,6 +18,13 @@ protected $name; /** + * Whether to include this field as a command-line option. + * + * @var bool + */ + protected $includeAsOption = true; + + /** * The command-line option name for the field. * * @see self::getAsOption() @@ -141,7 +148,8 @@ * An array mapping field keys (referencing other fields in the form) to * user input. If any conditions are defined, all of them must match the * user's input via self::matchesCondition(), otherwise the field will not - * be displayed. + * be displayed. If the condition is a callable, it will be called with + * one argument (the user input) and expected to return a boolean. */ protected $conditions = []; @@ -211,6 +219,10 @@ */ public function matchesCondition($userValue, $condition) { + if (is_callable($condition)) { + return $condition($userValue); + } + return $userValue === $condition; } @@ -271,6 +283,16 @@ } /** + * Returns whether to include this field as a command-line option. + * + * @return bool + */ + public function includeAsOption() + { + return $this->includeAsOption; + } + + /** * Get the field as a Console input option. * * @return InputOption @@ -410,13 +432,13 @@ if (!$input->hasOption($optionName)) { return null; } - if ($input->getParameterOption('--' . $optionName) === false) { - return null; - } $value = $input->getOption($optionName); if ($this->isEmpty($value)) { return null; } + if ($input->getParameterOption('--' . $optionName) === false && $value === $this->default) { + return null; + } return $normalize ? $this->normalize($value) : $value; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/OptionsField.php new/vendor/platformsh/console-form/src/Field/OptionsField.php --- old/vendor/platformsh/console-form/src/Field/OptionsField.php 2018-02-12 12:15:24.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/OptionsField.php 2018-03-20 20:18:47.000000000 +0100 @@ -9,6 +9,7 @@ protected $options = []; protected $asChoice = true; protected $allowOther = false; + protected $autoDescribe = true; /** * A callback used to calculate dynamic options. @@ -30,7 +31,7 @@ if ($this->allowOther) { return true; } - $options = $this->isNumeric() ? $this->options : array_keys($this->options); + $options = $this->validOptions(); return array_search($value, $options, true) !== false ? true : "$value is not one of: " . implode(', ', $options); @@ -38,10 +39,24 @@ } /** + * Return a list of valid option values. + * + * @return array + */ + private function validOptions() + { + return $this->isNumeric() ? $this->options : array_keys($this->options); + } + + /** * {@inheritdoc} */ public function matchesCondition($userValue, $condition) { + if (is_callable($condition)) { + return $condition($userValue); + } + return is_array($condition) ? in_array($userValue, $condition) : $userValue === $condition; @@ -94,10 +109,16 @@ protected function getDescription() { $description = parent::getDescription(); - if (!empty($this->options)) { - $optionsString = "'" . implode("', '", $this->options) . "'"; + $validOptions = $this->validOptions(); + if (!empty($validOptions) && $this->autoDescribe) { + $separator = count($validOptions) === 2 ? ' or ' : ', '; + $optionsString = "'" . implode("'$separator'", $this->validOptions()) . "'"; if (strlen($optionsString) < 255) { - $description .= ' (' . $optionsString . ')'; + $description .= ' ('; + if ($this->allowOther) { + $description .= 'e.g. '; + } + $description .= $optionsString . ')'; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Form.php new/vendor/platformsh/console-form/src/Form.php --- old/vendor/platformsh/console-form/src/Form.php 2018-02-12 12:15:24.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Form.php 2018-03-20 20:18:47.000000000 +0100 @@ -72,7 +72,9 @@ public function configureInputDefinition(InputDefinition $definition) { foreach ($this->fields as $field) { - $definition->addOption($field->getAsOption()); + if ($field->includeAsOption()) { + $definition->addOption($field->getAsOption()); + } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/tests/FormTest.php new/vendor/platformsh/console-form/tests/FormTest.php --- old/vendor/platformsh/console-form/tests/FormTest.php 2018-02-12 12:15:24.000000000 +0100 +++ new/vendor/platformsh/console-form/tests/FormTest.php 2018-03-20 20:18:47.000000000 +0100 @@ -422,6 +422,27 @@ $this->assertEquals($validResult, $result, 'Array input with array values passes'); } + public function testPresetInputOptions() + { + $definition = new InputDefinition(); + $this->form->configureInputDefinition($definition); + + $validResult = $this->validResult; + + $input = new ArgvInput([ + 'commandName', + '--test', $this->validString, + '--mail', $this->validMail, + ], $definition); + + $input->setOption('field-with-default', 'test string'); + $validResult['with_default'] = 'test string'; + + $input->setInteractive(false); + $result = $this->form->resolveOptions($input, new NullOutput(), $this->getQuestionHelper()); + $this->assertEquals($validResult, $result, 'Input with non-parameter value passes.'); + } + /** * @return QuestionHelper */