mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Dimplified GenerateKeyCommand by using SymfonyStyle
This commit is contained in:
parent
37fb7e76d9
commit
1993d01110
2 changed files with 6 additions and 2 deletions
|
@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Zend\I18n\Translator\TranslatorInterface;
|
||||
|
||||
class GenerateKeyCommand extends Command
|
||||
|
@ -46,6 +47,9 @@ class GenerateKeyCommand extends Command
|
|||
{
|
||||
$expirationDate = $input->getOption('expirationDate');
|
||||
$apiKey = $this->apiKeyService->create(isset($expirationDate) ? new \DateTime($expirationDate) : null);
|
||||
$output->writeln($this->translator->translate('Generated API key') . sprintf(': <info>%s</info>', $apiKey));
|
||||
|
||||
(new SymfonyStyle($input, $output))->success(
|
||||
sprintf($this->translator->translate('Generated API key: "%s"'), $apiKey)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,6 @@ class DisableKeyCommandTest extends TestCase
|
|||
'apiKey' => $apiKey,
|
||||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
$this->assertEquals('API key "abcd1234" does not exist.' . PHP_EOL, $output);
|
||||
$this->assertContains('API key "abcd1234" does not exist.', $output);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue