Skip to content

Commit ed81287

Browse files
committed
Pretty output for genkey command
1 parent b6e12eb commit ed81287

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Command/GenerateKeyCommand.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Console\Input\InputInterface;
99
use Symfony\Component\Console\Input\InputOption;
1010
use Symfony\Component\Console\Output\OutputInterface;
11+
use Symfony\Component\Console\Style\SymfonyStyle;
1112

1213
class GenerateKeyCommand extends Command
1314
{
@@ -35,29 +36,33 @@ protected function configure()
3536

3637
protected function execute(InputInterface $input, OutputInterface $output)
3738
{
39+
$io = new SymfonyStyle($input, $output);
40+
3841
$path = $input->getArgument(self::ARG_PATH);
3942

4043
if (\file_exists($path)) {
41-
$output->writeln("I cannot create a key file at \"{$path}\" because a file exists there already. I stop!");
44+
$io->error("I cannot create a key file at \"{$path}\" because a file exists there already. I stop!");
4245

4346
return 1;
4447
}
4548

46-
if (null !== $input->getOption(self::OPT_SIGNING)) {
49+
if ($input->getOption(self::OPT_SIGNING)) {
4750
if (true !== KeyFactory::save(KeyFactory::generateAuthenticationKey(), $path)) {
48-
$output->writeln("I tried, but was unable to write the signing key to a file at \"{$path}\". I apologise!");
51+
$io->error("I tried, but was unable to write the signing key to a file at \"{$path}\". I apologise!");
4952

5053
return 2;
5154
}
55+
$io->success("Signing key saved to \"{$path}\".");
5256

5357
return 0;
5458
}
5559

5660
if (true !== KeyFactory::save(KeyFactory::generateEncryptionKey(), $path)) {
57-
$output->writeln("I tried, but was unable to write the encryption key to a file at \"{$path}\". I apologise!");
61+
$io->error("I tried, but was unable to write the encryption key to a file at \"{$path}\". I apologise!");
5862

5963
return 2;
6064
}
65+
$io->success("Encryption key saved to \"{$path}\".");
6166

6267
return 0;
6368
}

0 commit comments

Comments
 (0)