8000 [FrameworkBundle] Add CLI completion to secrets:remove · symfony/symfony@7810d19 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7810d19

Browse files
committed
[FrameworkBundle] Add CLI completion to secrets:remove
1 parent ee3ee65 commit 7810d19

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
1515
use Symfony\Component\Console\Command\Command;
16+
use Symfony\Component\Console\Completion\CompletionInput;
17+
use Symfony\Component\Console\Completion\CompletionInterface;
18+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1619
use Symfony\Component\Console\Input\InputArgument;
1720
use Symfony\Component\Console\Input\InputInterface;
1821
use Symfony\Component\Console\Input\InputOption;
@@ -26,7 +29,7 @@
2629
*
2730
* @internal
2831
*/
29-
final class SecretsRemoveCommand extends Command
32+
final class SecretsRemoveCommand extends Command implements CompletionInterface
3033
{
3134
protected static $defaultName = 'secrets:remove';
3235
protected static $defaultDescription = 'Remove a secret from the vault';
@@ -80,4 +83,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8083

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

0 commit comments

Comments
 (0)
0