From f0e9f6dd935ba45e1947799eff43203279e0f202 Mon Sep 17 00:00:00 2001 From: Mathieu Ferment Date: Tue, 24 Jan 2017 20:53:25 +0100 Subject: [PATCH 1/2] Enable autocomplete for ask() --- src/functions.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/functions.php b/src/functions.php index df608db06..d8a3056f1 100644 --- a/src/functions.php +++ b/src/functions.php @@ -546,11 +546,16 @@ function has($name) /** * @param string $message * @param string|null $default + * @param string[]|null $suggestedChoices * @return string * @codeCoverageIgnore */ -function ask($message, $default = null) +function ask($message, $default = null, $suggestedChoices = null) { + if (($suggestedChoices !== null) && (empty($suggestedChoices))) { + throw new \InvalidArgumentException('Suggested choices should not be empty'); + } + if (isQuiet()) { return $default; } @@ -561,6 +566,10 @@ function ask($message, $default = null) $question = new Question($message, $default); + if (empty($suggestedChoices) === false) { + $question->setAutocompleterValues($suggestedChoices); + } + return $helper->ask(input(), output(), $question); } From dc3e7df7ae7a390fc559721a24d1588b71dc652d Mon Sep 17 00:00:00 2001 From: Mathieu Ferment Date: Wed, 25 Jan 2017 10:01:50 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 928d9f698..332d76639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Changed - `add()` now merges configuration options recursively [#962](https://github.com/deployphp/deployer/pull/962) - Added `writable_chmod_recursive` boolean option to enable non-recursive `chmod` +- `ask()` now supports autocomplete [#978](https://github.com/deployphp/deployer/pull/978) ## v4.1.0 [v4.0.2...v4.1.0](https://github.com/deployphp/deployer/compare/v4.0.2...v4.1.0)