|
8 | 8 | use Symfony\Component\Console\Input\InputInterface; |
9 | 9 | use Symfony\Component\Console\Input\InputOption; |
10 | 10 | use Symfony\Component\Console\Output\OutputInterface; |
| 11 | +use Symfony\Component\Console\Style\SymfonyStyle; |
11 | 12 |
|
12 | 13 | class GenerateKeyCommand extends Command |
13 | 14 | { |
@@ -35,29 +36,33 @@ protected function configure() |
35 | 36 |
|
36 | 37 | protected function execute(InputInterface $input, OutputInterface $output) |
37 | 38 | { |
| 39 | + $io = new SymfonyStyle($input, $output); |
| 40 | + |
38 | 41 | $path = $input->getArgument(self::ARG_PATH); |
39 | 42 |
|
40 | 43 | 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!"); |
42 | 45 |
|
43 | 46 | return 1; |
44 | 47 | } |
45 | 48 |
|
46 | | - if (null !== $input->getOption(self::OPT_SIGNING)) { |
| 49 | + if ($input->getOption(self::OPT_SIGNING)) { |
47 | 50 | 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!"); |
49 | 52 |
|
50 | 53 | return 2; |
51 | 54 | } |
| 55 | + $io->success("Signing key saved to \"{$path}\"."); |
52 | 56 |
|
53 | 57 | return 0; |
54 | 58 | } |
55 | 59 |
|
56 | 60 | 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!"); |
58 | 62 |
|
59 | 63 | return 2; |
60 | 64 | } |
| 65 | + $io->success("Encryption key saved to \"{$path}\"."); |
61 | 66 |
|
62 | 67 | return 0; |
63 | 68 | } |
|
0 commit comments