in src/shipit/phase/ShipItPhaseRunner.php [216:271]
protected static function printHelp(vec<ShipItCLIArgument> $config): void {
/* HH_FIXME[2050] Previously hidden by unsafe_expr */
$filename = $_SERVER['SCRIPT_NAME'];
$max_left = 0;
$rows = dict[];
foreach ($config as $opt) {
$description = Shapes::idx($opt, 'description');
if ($description === null) {
$replacement = Shapes::idx($opt, 'replacement');
if ($replacement !== null) {
continue;
} else {
invariant(
!Shapes::idx($opt, 'write'),
'--%s is undocumented, does something, and has no replacement',
$opt['long_name'],
);
$description = 'deprecated, no-op';
}
}
$short = Shapes::idx($opt, 'short_name');
$long = $opt['long_name'];
$is_optional = Str\slice($long, -2) === '::';
$is_required = !$is_optional && Str\slice($long, -1) === ':';
$long = Str\trim_right($long, ':');
$prefix = $short !== null ? '-'.Str\trim_right($short, ':').', ' : '';
$suffix = $is_optional ? "=VALUE" : ($is_required ? "=$long" : '');
$left = ' '.$prefix.'--'.$long.$suffix;
$max_left = Math\maxva(Str\length($left), $max_left);
$rows[$long] = tuple($left, $description);
}
$rows = Dict\sort_by_key($rows);
$help = $rows['help'];
unset($rows['help']);
$rows = Dict\merge(dict['help' => $help], $rows);
$opt_help = Str\join(
Dict\map(
$rows,
$row ==>
Str\format("%s %s\n", Str\pad_right($row[0], $max_left), $row[1]),
),
"",
);
echo <<<EOF
Usage:
{$filename} [options]
Options:
{$opt_help}
EOF;
}