Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
feat: add ask skipable to command
Browse files Browse the repository at this point in the history
  • Loading branch information
Muetze42 committed Oct 20, 2023
1 parent 6b62b43 commit 2da6397
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/LuraCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class LuraCommand extends Command
{
/**
* The Installer Configurations
* The Installer Configurations.
*
* @var array
*/
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 2da6397

Please sign in to comment.