|
|
@ -688,6 +688,7 @@ class CommandLine {
|
|
|
|
$pads->name = 0;
|
|
|
|
$pads->name = 0;
|
|
|
|
$pads->occurMin = 0;
|
|
|
|
$pads->occurMin = 0;
|
|
|
|
$pads->occurMax = 0;
|
|
|
|
$pads->occurMax = 0;
|
|
|
|
|
|
|
|
$pads->default = 0;
|
|
|
|
$pads->valueDescription = 0;
|
|
|
|
$pads->valueDescription = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Lecture des arguments
|
|
|
|
// Lecture des arguments
|
|
|
@ -698,17 +699,30 @@ class CommandLine {
|
|
|
|
$pads->occurMin = max($pads->occurMin, strlen($value->getOccurMin()));
|
|
|
|
$pads->occurMin = max($pads->occurMin, strlen($value->getOccurMin()));
|
|
|
|
$pads->occurMax = max($pads->occurMax, strlen(is_null($max) ? 'N' : $max));
|
|
|
|
$pads->occurMax = max($pads->occurMax, strlen(is_null($max) ? 'N' : $max));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pads->default = max($pads->default, strlen($value->getDefault()));
|
|
|
|
if ($value instanceof IArgumentValueDescription) {
|
|
|
|
if ($value instanceof IArgumentValueDescription) {
|
|
|
|
$pads->valueDescription = max($pads->valueDescription, strlen($value->getValueDescription()));
|
|
|
|
$pads->valueDescription = max($pads->valueDescription, strlen($value->getValueDescription()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$spaces = array();
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->name, ' ');
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->occurMin + 4 + $pads->occurMax, ' ');
|
|
|
|
|
|
|
|
if($pads->valueDescription > 0) {
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->valueDescription, ' ');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($pads->default > 0) {
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->default, ' ');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$spaces[] = '';
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Génération des descriptifs
|
|
|
|
* Génération des descriptifs
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$entries = array();
|
|
|
|
$entries = array();
|
|
|
|
foreach ($values as $value) {
|
|
|
|
foreach ($values as $value) {
|
|
|
|
$label = str_pad($value->getName(), $pads->name, ' ', STR_PAD_RIGHT);
|
|
|
|
$entry = array();
|
|
|
|
|
|
|
|
$entry[] = str_pad($value->getName(), $pads->name, ' ', STR_PAD_RIGHT);
|
|
|
|
|
|
|
|
|
|
|
|
$max = $value->getOccurMax();
|
|
|
|
$max = $value->getOccurMax();
|
|
|
|
|
|
|
|
|
|
|
@ -716,35 +730,27 @@ class CommandLine {
|
|
|
|
$occur .= str_pad($value->getOccurMin(), $pads->occurMin, ' ', STR_PAD_LEFT);
|
|
|
|
$occur .= str_pad($value->getOccurMin(), $pads->occurMin, ' ', STR_PAD_LEFT);
|
|
|
|
$occur .= ' => ';
|
|
|
|
$occur .= ' => ';
|
|
|
|
$occur .= str_pad(is_null($max) ? 'N' : $max, $pads->occurMax, ' ', STR_PAD_RIGHT);
|
|
|
|
$occur .= str_pad(is_null($max) ? 'N' : $max, $pads->occurMax, ' ', STR_PAD_RIGHT);
|
|
|
|
|
|
|
|
$entry[] = $occur;
|
|
|
|
|
|
|
|
|
|
|
|
$valueDescription = str_pad(
|
|
|
|
if($pads->valueDescription > 0) {
|
|
|
|
|
|
|
|
$entry[] = str_pad(
|
|
|
|
$value instanceof IArgumentValueDescription ? $value->getValueDescription() : '',
|
|
|
|
$value instanceof IArgumentValueDescription ? $value->getValueDescription() : '',
|
|
|
|
$pads->valueDescription,
|
|
|
|
$pads->valueDescription,
|
|
|
|
' ',
|
|
|
|
' ',
|
|
|
|
STR_PAD_RIGHT
|
|
|
|
STR_PAD_RIGHT
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($pads->default > 0) {
|
|
|
|
|
|
|
|
$entry[] = str_pad($value->getDefault(), $pads->default, ' ', STR_PAD_RIGHT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$entries[] = self::TAB . implode(
|
|
|
|
$entry[] = preg_replace(
|
|
|
|
self::TAB,
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
$label,
|
|
|
|
|
|
|
|
$occur,
|
|
|
|
|
|
|
|
$valueDescription,
|
|
|
|
|
|
|
|
preg_replace(
|
|
|
|
|
|
|
|
'@\r?\n@',
|
|
|
|
'@\r?\n@',
|
|
|
|
'$0' . self::TAB . implode(
|
|
|
|
'$0' . self::TAB . implode(self::TAB, $spaces),
|
|
|
|
self::TAB,
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
str_pad('', $pads->name, ' '),
|
|
|
|
|
|
|
|
str_pad('', $pads->occurMin + 4 + $pads->occurMax, ' '),
|
|
|
|
|
|
|
|
str_pad('', $pads->valueDescription, ' '),
|
|
|
|
|
|
|
|
'',
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
$value->getDescription()
|
|
|
|
$value->getDescription()
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$entries[] = self::TAB . implode(self::TAB, $entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $entries;
|
|
|
|
return $entries;
|
|
|
@ -764,6 +770,7 @@ class CommandLine {
|
|
|
|
$pads = new stdClass;
|
|
|
|
$pads = new stdClass;
|
|
|
|
$pads->tagShort = 0;
|
|
|
|
$pads->tagShort = 0;
|
|
|
|
$pads->tagLong = 0;
|
|
|
|
$pads->tagLong = 0;
|
|
|
|
|
|
|
|
$pads->default = 0;
|
|
|
|
$pads->valueDescription = 0;
|
|
|
|
$pads->valueDescription = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Lecture des arguments
|
|
|
|
// Lecture des arguments
|
|
|
@ -774,6 +781,7 @@ class CommandLine {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pads->tagLong = max($pads->tagLong, strlen($option->getTagLong()));
|
|
|
|
$pads->tagLong = max($pads->tagLong, strlen($option->getTagLong()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pads->default = max($pads->default, strlen($option->getDefault()));
|
|
|
|
if ($option instanceof IArgumentValueDescription) {
|
|
|
|
if ($option instanceof IArgumentValueDescription) {
|
|
|
|
$pads->valueDescription = max($pads->valueDescription, strlen($option->getValueDescription()));
|
|
|
|
$pads->valueDescription = max($pads->valueDescription, strlen($option->getValueDescription()));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -783,11 +791,23 @@ class CommandLine {
|
|
|
|
$pads->tagShort += 1;
|
|
|
|
$pads->tagShort += 1;
|
|
|
|
$pads->tagLong += 2;
|
|
|
|
$pads->tagLong += 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$spaces = array();
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->tagShort + 1 + $pads->tagLong + 2, ' ');
|
|
|
|
|
|
|
|
if($pads->valueDescription > 0) {
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->valueDescription, ' ');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($pads->default > 0) {
|
|
|
|
|
|
|
|
$spaces[] = str_pad('', $pads->default, ' ');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$spaces[] = '';
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Génération des descriptifs
|
|
|
|
* Génération des descriptifs
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$entries = array();
|
|
|
|
$entries = array();
|
|
|
|
foreach ($options as $option) {
|
|
|
|
foreach ($options as $option) {
|
|
|
|
|
|
|
|
$entry = array();
|
|
|
|
|
|
|
|
|
|
|
|
$short = $option->getTagShort();
|
|
|
|
$short = $option->getTagShort();
|
|
|
|
|
|
|
|
|
|
|
|
$label = '';
|
|
|
|
$label = '';
|
|
|
@ -795,33 +815,28 @@ class CommandLine {
|
|
|
|
$label .= ' ';
|
|
|
|
$label .= ' ';
|
|
|
|
$label .= str_pad('--' . $option->getTagLong(), $pads->tagLong, ' ', STR_PAD_RIGHT);
|
|
|
|
$label .= str_pad('--' . $option->getTagLong(), $pads->tagLong, ' ', STR_PAD_RIGHT);
|
|
|
|
$label .= $option->allowMultiple() ? ' *' : ($option->isStoppingParse() ? ' X' : ' ');
|
|
|
|
$label .= $option->allowMultiple() ? ' *' : ($option->isStoppingParse() ? ' X' : ' ');
|
|
|
|
|
|
|
|
$entry[] = $label;
|
|
|
|
|
|
|
|
|
|
|
|
$valueDescription = str_pad(
|
|
|
|
if($pads->valueDescription) {
|
|
|
|
|
|
|
|
$entry[] = str_pad(
|
|
|
|
$option instanceof IArgumentValueDescription ? $option->getValueDescription() : '',
|
|
|
|
$option instanceof IArgumentValueDescription ? $option->getValueDescription() : '',
|
|
|
|
$pads->valueDescription,
|
|
|
|
$pads->valueDescription,
|
|
|
|
' ',
|
|
|
|
' ',
|
|
|
|
STR_PAD_RIGHT
|
|
|
|
STR_PAD_RIGHT
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$entries[] = self::TAB . implode(
|
|
|
|
if($pads->default > 0) {
|
|
|
|
self::TAB,
|
|
|
|
$entry[] = str_pad($option->getDefault(), $pads->default, ' ', STR_PAD_RIGHT);
|
|
|
|
array(
|
|
|
|
}
|
|
|
|
$label,
|
|
|
|
|
|
|
|
$valueDescription,
|
|
|
|
$entry[] = preg_replace(
|
|
|
|
preg_replace(
|
|
|
|
|
|
|
|
'@\r?\n@',
|
|
|
|
'@\r?\n@',
|
|
|
|
'$0' . self::TAB . self::TAB . implode(
|
|
|
|
'$0' . self::TAB . implode(self::TAB, $spaces),
|
|
|
|
self::TAB,
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
str_pad('', $pads->tagShort + 1 + $pads->tagLong + 2, ' '),
|
|
|
|
|
|
|
|
str_pad('', $pads->valueDescription, ' '),
|
|
|
|
|
|
|
|
'',
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
$option->getDescription()
|
|
|
|
$option->getDescription()
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$entries[] = self::TAB . implode(self::TAB, $entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $entries;
|
|
|
|
return $entries;
|
|
|
|