MDL-67687 cli: Make boolean CLI args negatable

This commit is contained in:
Andrew Nicols 2020-06-15 12:38:56 +08:00
parent 07238ca511
commit b0e096d870

View File

@ -105,6 +105,12 @@ function cli_get_params(array $longoptions, array $shortmapping=null) {
if (count($parts) == 1) {
$key = reset($parts);
$value = true;
if (substr($key, 0, 3) === 'no-') {
// Support flipping the boolean value.
$value = !$value;
$key = substr($key, 3);
}
} else {
$key = array_shift($parts);
$value = implode('=', $parts);