allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
53
vendor/laravel/prompts/src/ConfirmPrompt.php
vendored
Normal file
53
vendor/laravel/prompts/src/ConfirmPrompt.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Prompts;
|
||||
|
||||
use Closure;
|
||||
|
||||
class ConfirmPrompt extends Prompt
|
||||
{
|
||||
/**
|
||||
* Whether the prompt has been confirmed.
|
||||
*/
|
||||
public bool $confirmed;
|
||||
|
||||
/**
|
||||
* Create a new ConfirmPrompt instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public string $label,
|
||||
public bool $default = true,
|
||||
public string $yes = 'Yes',
|
||||
public string $no = 'No',
|
||||
public bool|string $required = false,
|
||||
public mixed $validate = null,
|
||||
public string $hint = '',
|
||||
public ?Closure $transform = null,
|
||||
) {
|
||||
$this->confirmed = $default;
|
||||
|
||||
$this->on('key', fn ($key) => match ($key) {
|
||||
'y' => $this->confirmed = true,
|
||||
'n' => $this->confirmed = false,
|
||||
Key::TAB, Key::UP, Key::UP_ARROW, Key::DOWN, Key::DOWN_ARROW, Key::LEFT, Key::LEFT_ARROW, Key::RIGHT, Key::RIGHT_ARROW, Key::CTRL_P, Key::CTRL_F, Key::CTRL_N, Key::CTRL_B, 'h', 'j', 'k', 'l' => $this->confirmed = ! $this->confirmed,
|
||||
Key::ENTER => $this->submit(),
|
||||
default => null,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the prompt.
|
||||
*/
|
||||
public function value(): bool
|
||||
{
|
||||
return $this->confirmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label of the selected option.
|
||||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return $this->confirmed ? $this->yes : $this->no;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user