Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CLI prompt validation message #7977

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static function init()
* Named options must be in the following formats:
* php index.php user -v --v -name=John --name=John
*
* @param string $prefix You may specify a string with which to prompt the user.
* @param string|null $prefix You may specify a string with which to prompt the user.
*/
public static function input(?string $prefix = null): string
{
Expand Down Expand Up @@ -210,9 +210,9 @@ public static function input(?string $prefix = null): string
* // Do not provide options but requires a valid email
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
*
* @param string $field Output "field" question
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param array|string $validation Validation rules
* @param string $field Output "field" question
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param array|string|null $validation Validation rules
*
* @return string The user input
*
Expand Down Expand Up @@ -258,7 +258,7 @@ public static function prompt(string $field, $options = null, $validation = null
$input = trim(static::input()) ?: $default;

if ($validation) {
while (! static::validate(trim($field), $input, $validation)) {
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {
$input = static::prompt($field, $options, $validation);
}
}
Expand Down Expand Up @@ -448,7 +448,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str
}

/**
* Outputs a string to the cli on it's own line.
* Outputs a string to the cli on its own line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤗 Your English is great.

*
* @return void
*/
Expand Down Expand Up @@ -574,10 +574,10 @@ public static function clearScreen()
* Returns the given text with the correct color codes for a foreground and
* optionally a background color.
*
* @param string $text The text to color
* @param string $foreground The foreground color
* @param string $background The background color
* @param string $format Other formatting to apply. Currently only 'underline' is understood
* @param string $text The text to color
* @param string $foreground The foreground color
* @param string|null $background The background color
* @param string|null $format Other formatting to apply. Currently only 'underline' is understood
*
* @return string The color coded string
*/
Expand Down Expand Up @@ -834,7 +834,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
* width.
*
* If an int is passed into $pad_left, then all strings after the first
* will padded with that many spaces to the left. Useful when printing
* will pad with that many spaces to the left. Useful when printing
* short descriptions that need to start on an existing line.
*/
public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string
Expand Down
Loading