public function InputDefinition::getSynopsis in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Input/InputDefinition.php \Symfony\Component\Console\Input\InputDefinition::getSynopsis()
Gets the synopsis.
Parameters
bool $short Whether to return the short version (with options folded) or not:
Return value
string The synopsis
File
- vendor/
symfony/ console/ Input/ InputDefinition.php, line 368
Class
- InputDefinition
- A InputDefinition represents a set of valid command line arguments and options.
Namespace
Symfony\Component\Console\InputCode
public function getSynopsis($short = false) {
$elements = array();
if ($short && $this
->getOptions()) {
$elements[] = '[options]';
}
elseif (!$short) {
foreach ($this
->getOptions() as $option) {
$value = '';
if ($option
->acceptValue()) {
$value = sprintf(' %s%s%s', $option
->isValueOptional() ? '[' : '', strtoupper($option
->getName()), $option
->isValueOptional() ? ']' : '');
}
$shortcut = $option
->getShortcut() ? sprintf('-%s|', $option
->getShortcut()) : '';
$elements[] = sprintf('[%s--%s%s]', $shortcut, $option
->getName(), $value);
}
}
if (count($elements) && $this
->getArguments()) {
$elements[] = '[--]';
}
foreach ($this
->getArguments() as $argument) {
$element = '<' . $argument
->getName() . '>';
if (!$argument
->isRequired()) {
$element = '[' . $element . ']';
}
elseif ($argument
->isArray()) {
$element = $element . ' (' . $element . ')';
}
if ($argument
->isArray()) {
$element .= '...';
}
$elements[] = $element;
}
return implode(' ', $elements);
}