8000 [Console] Improved rendering of optional arguments in command synopsis by AnrDaemon · Pull Request #26417 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Improved rendering of optional arguments in command synopsis #26417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improved rendering of optional arguments in command synopsis.
Current rendering:
```
  build [options] [--] [<file>] [<output-dir>] [<packages>]...
```
Fixed (and actually correct) rendering:
```
  build [options] [--] [<file> [<output-dir> [<packages>...]]]
```

Also dropped duplicating required array-type argument. There's just no need for that, it only confuses the reader.
  • Loading branch information
AnrDaemon committed Mar 5, 2018
commit 037162b2203da719f3d8ded8819cfdfa7c913bbd
14 changes: 7 additions & 7 deletions src/Symfony/Component/Console/Input/InputDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,21 @@ public function getSynopsis($short = false)
$elements[] = '[--]';
}

$tail = '';
foreach ($this->getArguments() as $argument) {
$element = '<'.$argument->getName().'>';
if (!$argument->isRequired()) {
$element = '['.$element.']';
} elseif ($argument->isArray()) {
$element = $element.' ('.$element.')';
}

if ($argument->isArray()) {
$element .= '...';
}

if (!$argument->isRequired()) {
$element = '['.$element;
$tail .= ']';
}

$elements[] = $element;
}

return implode(' ', $elements);
return implode(' ', $elements) . $tail;
}
}
0