Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf79ed9a

Browse files
committed
bug#46386 [Console]  Fix missing negative variation of negatable options in shell completion (GromNaN)
This PR was merged into the 5.4 branch.Discussion----------[Console]  Fix missing negative variation of negatable options in shell completion| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | n/a| License | MIT| Doc PR | n/aAdd negation of [negatable options](https://symfony.com/blog/new-in-symfony-5-3-negatable-command-options) in bash completion output.2nd PR for Fish, targeting branch 6.1:#46387Commits-------a3da680 Complete negatable options
2 parents87105b4 +a3da680 commitf79ed9a

File tree

4 files changed

+89
-2
lines changed

4 files changed

+89
-2
lines changed

‎src/Symfony/Component/Console/Completion/Output/BashCompletionOutput.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public function write(CompletionSuggestions $suggestions, OutputInterface $outpu
2424
$values =$suggestions->getValueSuggestions();
2525
foreach ($suggestions->getOptionSuggestions()as$option) {
2626
$values[] ='--'.$option->getName();
27+
if ($option->isNegatable()) {
28+
$values[] ='--no-'.$option->getName();
29+
}
2730
}
2831
$output->writeln(implode("\n",$values));
2932
}

‎src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ public function testCompleteCommandInputDefinition(array $input, array $suggesti
119119

120120
publicfunctionprovideCompleteCommandInputDefinitionInputs()
121121
{
122-
yield'definition' => [['bin/console','hello','-'], ['--help','--quiet','--verbose','--version','--ansi','--no-interaction']];
122+
yield'definition' => [['bin/console','hello','-'], ['--help','--quiet','--verbose','--version','--ansi','--no-ansi','--no-interaction']];
123123
yield'custom' => [['bin/console','hello'], ['Fabien','Robin','Wouter']];
124-
yield'definition-aliased' => [['bin/console','ahoy','-'], ['--help','--quiet','--verbose','--version','--ansi','--no-interaction']];
124+
yield'definition-aliased' => [['bin/console','ahoy','-'], ['--help','--quiet','--verbose','--version','--ansi','--no-ansi','--no-interaction']];
125125
yield'custom-aliased' => [['bin/console','ahoy'], ['Fabien','Robin','Wouter']];
126126
}
127127

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Console\Tests\Completion\Output;
13+
14+
useSymfony\Component\Console\Completion\Output\BashCompletionOutput;
15+
useSymfony\Component\Console\Completion\Output\CompletionOutputInterface;
16+
17+
class BashCompletionOutputTestextends CompletionOutputTestCase
18+
{
19+
publicfunctiongetCompletionOutput():CompletionOutputInterface
20+
{
21+
returnnewBashCompletionOutput();
22+
}
23+
24+
publicfunctiongetExpectedOptionsOutput():string
25+
{
26+
return"--option1\n--negatable\n--no-negatable".\PHP_EOL;
27+
}
28+
29+
publicfunctiongetExpectedValuesOutput():string
30+
{
31+
return"Green\nRed\nYellow".\PHP_EOL;
32+
}
33+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Console\Tests\Completion\Output;
13+
14+
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\Console\Completion\CompletionSuggestions;
16+
useSymfony\Component\Console\Completion\Output\CompletionOutputInterface;
17+
useSymfony\Component\Console\Input\InputOption;
18+
useSymfony\Component\Console\Output\StreamOutput;
19+
20+
abstractclass CompletionOutputTestCaseextends TestCase
21+
{
22+
abstractpublicfunctiongetCompletionOutput():CompletionOutputInterface;
23+
24+
abstractpublicfunctiongetExpectedOptionsOutput():string;
25+
26+
abstractpublicfunctiongetExpectedValuesOutput():string;
27+
28+
publicfunctiontestOptionsOutput()
29+
{
30+
$options = [
31+
newInputOption('option1','o', InputOption::VALUE_NONE),
32+
newInputOption('negatable',null, InputOption::VALUE_NEGATABLE),
33+
];
34+
$suggestions =newCompletionSuggestions();
35+
$suggestions->suggestOptions($options);
36+
$stream =fopen('php://memory','rw+');
37+
$this->getCompletionOutput()->write($suggestions,newStreamOutput($stream));
38+
fseek($stream,0);
39+
$this->assertEquals($this->getExpectedOptionsOutput(),stream_get_contents($stream));
40+
}
41+
42+
publicfunctiontestValuesOutput()
43+
{
44+
$suggestions =newCompletionSuggestions();
45+
$suggestions->suggestValues(['Green','Red','Yellow']);
46+
$stream =fopen('php://memory','rw+');
47+
$this->getCompletionOutput()->write($suggestions,newStreamOutput($stream));
48+
fseek($stream,0);
49+
$this->assertEquals($this->getExpectedValuesOutput(),stream_get_contents($stream));
50+
}
51+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp