Skip to content

Commit

Permalink
chore: update some for format message render
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 27, 2021
1 parent cd448f2 commit e4a2695
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/Component/Interact/Choose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Concern/StyledOutputAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Util/FormatUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e4a2695

Please sign in to comment.