Skip to content

Commit

Permalink
CLI: Select: Simplify things and multibyte support for the keys
Browse files Browse the repository at this point in the history
Signed-off-by: Wolf Wortmann <[email protected]>
  • Loading branch information
element-code committed Feb 2, 2021
1 parent 68d4e74 commit 1fa44d0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,13 @@ public static function promptSelect(string $text, array $options, $validation =

CLI::write($text);

$keyMaxLength = max(array_map('strlen', array_keys($options)));
$keys = [];
$keyMaxLength = max(array_map('mb_strlen', array_keys($options)));
foreach ($options as $key => $description){
$keys[] = (string) $key;
$name = ' ' . str_pad($key, $keyMaxLength + 2, ' ');

CLI::write($name . CLI::wrap($description, 125, strlen($name)));
}

return static::prompt(PHP_EOL, $keys, $validation);
return static::prompt(PHP_EOL, array_keys($options), $validation);
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit 1fa44d0

Please sign in to comment.