Skip to content

Commit a738614

Browse files
committed
allow command security:custom with name in argument to no interraction
1 parent 0624f13 commit a738614

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Maker/Security/MakeCustomAuthenticator.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
2525
use Symfony\Bundle\MakerBundle\Validator;
2626
use Symfony\Component\Console\Command\Command;
27+
use Symfony\Component\Console\Input\InputArgument;
2728
use Symfony\Component\Console\Input\InputInterface;
2829
use Symfony\Component\HttpFoundation\JsonResponse;
2930
use Symfony\Component\HttpFoundation\Request;
@@ -68,8 +69,10 @@ public static function getCommandDescription(): string
6869
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
6970
{
7071
$command
72+
->addArgument('name', InputArgument::OPTIONAL, 'The class name of the authenticator (e.g. <fg=yellow>CustomAuthenticator</>)')
7173
->setHelp($this->getHelpFileContents('security/MakeCustom.txt'))
7274
;
75+
$inputConfig->setArgumentAsNonInteractive('name');
7376
}
7477

7578
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
@@ -84,7 +87,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
8487
throw new RuntimeCommandException(\sprintf('The file "%s" does not exist. PHP & XML configuration formats are currently not supported.', self::SECURITY_CONFIG_PATH));
8588
}
8689

87-
$name = $io->ask(
90+
$name = $input->getArgument('name') ?? $io->ask(
8891
question: 'What is the class name of the authenticator (e.g. <fg=yellow>CustomAuthenticator</>)',
8992
validator: static function (mixed $answer) {
9093
return Validator::notBlank($answer);

0 commit comments

Comments
 (0)