src/Helpers/Console.php
public static function prompt($text, $options = [])
    {
        $options = ArrayHelper::merge(
            [
                'required' => false,
                'default' => null,
                'pattern' => null,
                'validator' => null,
                'error' => 'Invalid input.',
            ],
            $options
        );
        $error = null;

        $basePromptFunc =
            function() use ($text, $options) {
            return $options['default']
                ? static::input("$text [" . $options['default'] . '] ')
                : static::input("$text ");
        };

        return $basePromptFunc()->then(static::promptValidationCallback($options, $basePromptFunc, $error));
    }
public static function prompt($text, $options = [])
    {
        $options = ArrayHelper::merge(
            [
                'required' => false,
                'default' => null,
                'pattern' => null,
                'validator' => null,
                'error' => 'Invalid input.',
            ],
            $options
        );
        $error = null;

        $basePromptFunc =
            function() use ($text, $options) {
            return $options['default']
                ? static::input("$text [" . $options['default'] . '] ')
                : static::input("$text ");
        };

        return $basePromptFunc()->then(static::promptValidationCallback($options, $basePromptFunc, $error));
    }
Prompts the user for input and validates it.

@param string $text prompt string
@param array $options the options to validate the input:

- `required`: whether it is required or not
- `default`: default value if no input is inserted by the user
- `pattern`: regular expression pattern to validate user input
- `validator`: a callable function to validate input. The function must accept two parameters:
- `input`: the user input to validate
- `error`: the error value passed by reference if validation failed.

@return ExtendedPromiseInterface with string the user input