From 2da63970168ce6620dc0353a4ed47c291fbc1176 Mon Sep 17 00:00:00 2001 From: Norman Huth Date: Fri, 20 Oct 2023 20:57:59 +0200 Subject: [PATCH] feat: add ask skipable to command --- src/LuraCommand.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/LuraCommand.php b/src/LuraCommand.php index 6099931..ac3b94b 100644 --- a/src/LuraCommand.php +++ b/src/LuraCommand.php @@ -19,7 +19,7 @@ class LuraCommand extends Command { /** - * The Installer Configurations + * The Installer Configurations. * * @var array */ @@ -358,4 +358,23 @@ public function replaceNth(string $pattern, string $replace, string $subject, in return $m[0]; }, $subject); } + + /** + * Prompt the user for skippable input. + * + * @param string $question + * @param string|null $default + * + * @return mixed + */ + public function askSkippable(string $question, string $default = null): mixed + { + $question = $this->ask(trim($question) . ' [n to skip]', $default = null); + + if (strtolower($question) == 'n') { + $question = null; + } + + return $question; + } }