Skip to content

Commit 15e9675

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [FrameworkBundle] Add CLI completion to secrets:remove [Console] Bash completion integration
2 parents 0b9eb17 + 2bb6dc8 commit 15e9675

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Command/SecretsRemoveCommand.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Completion\CompletionInput;
18+
use Symfony\Component\Console\Completion\CompletionInterface;
19+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1720
use Symfony\Component\Console\Input\InputArgument;
1821
use Symfony\Component\Console\Input\InputInterface;
1922
use Symfony\Component\Console\Input\InputOption;
@@ -28,7 +31,7 @@
2831
* @internal
2932
*/
3033
#[AsCommand(name: 'secrets:remove', description: 'Remove a secret from the vault')]
31-
final class SecretsRemoveCommand extends Command
34+
final class SecretsRemoveCommand extends Command implements CompletionInterface
3235
{
3336
private $vault;
3437
private $localVault;
@@ -78,4 +81,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7881

7982
return 0;
8083
}
84+
85+
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
86+
{
87+
if (!$input->mustSuggestArgumentValuesFor('name')) {
88+
return;
89+
}
90+
91+
$vault = $input->getOption('local') ? $this->localVault : $this->vault;
92+
$vaultKeys = array_keys($this->vault->list(false));
93+
$suggestions->suggestValues(array_intersect($vaultKeys, array_keys($vault->list(false))));
94+
}
8195
}

0 commit comments

Comments
 (0)