in src/CLIBase.hack [292:334]
private static function extractOptions(
string $arg,
CLIOptions\CLIOptionType $type,
): dict<string, ?string> {
$options = vec[];
switch ($type) {
case CLIOptions\CLIOptionType::LONG:
$options[] = $arg;
break;
case CLIOptions\CLIOptionType::SHORT:
$equal_sign_position = Str\search($arg, '=', 0);
if ($equal_sign_position !== null && $equal_sign_position !== 1) {
throw new InvalidArgumentException(
'It is restricted to use value assignment in multiple usage of short syntax: -%s',
$arg,
);
}
if ($equal_sign_position === null) {
$options = Vec\concat($options, Str\chunk($arg));
} else {
$options[] = $arg;
}
break;
default:
break;
}
$is_single_option = C\count($options) === 1;
if ($is_single_option) {
$value = null;
$option = C\onlyx($options);
if (Str\contains($option, '=')) {
$parts = Str\split($option, '=');
$option = $parts[0];
$value = Str\join(Vec\drop($parts, 1), '=');
}
$result = dict[
$option => $value,
];
} else {
$result = Dict\fill_keys($options, null);
}
return $result;
}