mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-02 21:12:02 +08:00
Improved imapsync.php options detection
This commit is contained in:
parent
2e3e1fa5fe
commit
3012084184
1 changed files with 6 additions and 4 deletions
|
@ -100,16 +100,18 @@ function get_opt(string $short_options, array $long_options) {
|
|||
}
|
||||
}
|
||||
// When empty, prompt on command line for value
|
||||
if (($required || $optional) && isset($opts[$key]) && !\strlen($opts[$key])) {
|
||||
if (($required && empty($opts[$key]))
|
||||
|| ($optional && isset($opts[$key]) && !\strlen($opts[$key]))
|
||||
) {
|
||||
if (\is_callable('readline')) {
|
||||
$opts[$key] = \readline("{$key}: ");
|
||||
} else {
|
||||
echo "{$key}: ";
|
||||
$opts[$key] = \stream_get_line(STDIN, 1024, PHP_EOL);
|
||||
}
|
||||
}
|
||||
if ($required && !isset($opts[$key])) {
|
||||
exit("Missing required argument {$arg}");
|
||||
if ($required && empty($opts[$key])) {
|
||||
exit("Missing required argument {$arg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return $opts;
|
||||
|
|
Loading…
Reference in a new issue