Skip to content

Commit 73a4a36

Browse files
committed
[Console] unmerge application args when needed
1 parent fad545a commit 73a4a36

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/Symfony/Component/Console/Command/Command.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,19 @@ public function setCode($code)
294294
public function mergeApplicationDefinition($mergeArgs = true)
295295
{
296296
if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
297+
if (!$mergeArgs && $this->applicationDefinitionMergedWithArgs) {
298+
$commandArgs = array_udiff(
299+
$this->definition->getArguments(),
300+
$this->application->getDefinition()->getArguments(),
301+
function ($arg1, $arg2) {
302+
return strcmp($arg1->getName(), $arg2->getName());
303+
}
304+
);
305+
306+
$this->definition->setArguments($commandArgs);
307+
$this->applicationDefinitionMergedWithArgs = false;
308+
}
309+
297310
return;
298311
}
299312

src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Usage:
22
help [options] [--] [<command_name>]
33

44
Arguments:
5-
command The command to execute
65
command_name The command name [default: "help"]
76

87
Options:

src/Symfony/Component/Console/Tests/Fixtures/command_astext.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
namespace:name
33
name
44

5-
<comment>Arguments:</comment>
6-
<info>command</info> The command to execute
7-
85
<comment>Options:</comment>
96
<info>-h, --help</info> Display this help message
107
<info>-q, --quiet</info> Do not output any message

src/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
</usages>
77
<description>description</description>
88
<help>help</help>
9-
<arguments>
10-
<argument name="command" is_required="1" is_array="0">
11-
<description>The command to execute</description>
12-
<defaults/>
13-
</argument>
14-
</arguments>
9+
<arguments/>
1510
<options>
1611
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
1712
<description>Display this help message</description>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy