From e4a269512151bda1c029a9f536acb7d6e60531af Mon Sep 17 00:00:00 2001 From: Inhere Date: Wed, 27 Oct 2021 21:36:16 +0800 Subject: [PATCH] chore: update some for format message render --- src/Component/Interact/Choose.php | 6 +++++- src/Concern/StyledOutputAwareTrait.php | 10 +++++----- src/Util/FormatUtil.php | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Component/Interact/Choose.php b/src/Component/Interact/Choose.php index 301e2ae..85b6f97 100644 --- a/src/Component/Interact/Choose.php +++ b/src/Component/Interact/Choose.php @@ -11,8 +11,11 @@ use Inhere\Console\Console; use Inhere\Console\Util\Show; +use Toolkit\Cli\Cli; use function array_key_exists; +use function array_keys; use function explode; +use function implode; use function is_array; use function trim; @@ -51,7 +54,7 @@ public static function one(string $description, $options, $default = null, bool // If default option is error if (null !== $default && !isset($options[$default])) { - Show::error("The default option [{$default}] don't exists.", true); + Show::error("The default option [$default] don't exists.", true); } if ($allowExit) { @@ -75,6 +78,7 @@ public static function one(string $description, $options, $default = null, bool // error, allow try again once. if (!array_key_exists($r, $options)) { + Cli::warn('[WARN] input must in the list: ' . implode(',', array_keys($options))); goto beginChoice; } diff --git a/src/Concern/StyledOutputAwareTrait.php b/src/Concern/StyledOutputAwareTrait.php index 2c7c2b2..9bc85e9 100644 --- a/src/Concern/StyledOutputAwareTrait.php +++ b/src/Concern/StyledOutputAwareTrait.php @@ -60,12 +60,12 @@ * * @method Generator counterTxt($msg = 'Pending ', $ended = false) * - * @method confirm(string $question, bool $default = true): bool - * @method unConfirm(string $question, bool $default = true): bool + * @method bool confirm(string $question, bool $default = true) + * @method bool unConfirm(string $question, bool $default = true) * @method string select(string $description, $options, $default = null, bool $allowExit = true, array $opts = []) - * @method checkbox(string $description, $options, $default = null, bool $allowExit = true): array - * @method ask(string $question, string $default = '', Closure $validator = null): string - * @method askPassword(string $prompt = 'Enter Password:'): string + * @method array checkbox(string $description, $options, $default = null, bool $allowExit = true) + * @method string ask(string $question, string $default = '', Closure $validator = null) + * @method string askPassword(string $prompt = 'Enter Password:') * @see Interact */ trait StyledOutputAwareTrait diff --git a/src/Util/FormatUtil.php b/src/Util/FormatUtil.php index ba43c24..805cc66 100644 --- a/src/Util/FormatUtil.php +++ b/src/Util/FormatUtil.php @@ -19,11 +19,13 @@ use function array_merge; use function array_shift; use function explode; +use function get_class; use function implode; use function is_array; use function is_bool; use function is_int; use function is_numeric; +use function is_object; use function is_scalar; use function rtrim; use function str_repeat; @@ -272,6 +274,8 @@ public static function spliceKeyValue(array $data, array $opts = []): string } $value = rtrim($temp, ' ,') . ']'; + // } elseif (is_object($value)) { + // $value = get_class($value); } elseif (is_bool($value)) { $value = $value ? '(True)' : '(False)'; } else { // to string.