in pp3/au/lib/Getopt.php [594:633]
public function getUsageMessage()
{
$usage = "Usage: {$this->_progname} [ options ]\n";
$maxLen = 20;
$lines = array();
foreach ($this->_rules as $rule) {
$flags = array();
if (is_array($rule['alias'])) {
foreach ($rule['alias'] as $flag) {
$flags[] = (strlen($flag) == 1 ? '-' : '--') . $flag;
}
}
$linepart['name'] = implode('|', $flags);
if (isset($rule['param']) && $rule['param'] != 'none') {
$linepart['name'] .= ' ';
switch ($rule['param']) {
case 'optional':
$linepart['name'] .= "[ <{$rule['paramType']}> ]";
break;
case 'required':
$linepart['name'] .= "<{$rule['paramType']}>";
break;
}
}
if (strlen($linepart['name']) > $maxLen) {
$maxLen = strlen($linepart['name']);
}
$linepart['help'] = '';
if (isset($rule['help'])) {
$linepart['help'] .= $rule['help'];
}
$lines[] = $linepart;
}
foreach ($lines as $linepart) {
$usage .= sprintf("%s %s\n",
str_pad($linepart['name'], $maxLen),
$linepart['help']);
}
return $usage;
}