Skip to content

Commit e0163d6

Browse files
committed
Convert InstallCommand and UpdateCommand into invokable commands
1 parent ca4f893 commit e0163d6

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

src/Command/InstallCommand.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Shlinkio\Shlink\Installer\Command;
66

77
use Shlinkio\Shlink\Installer\Service\InstallationRunnerInterface;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
9-
use Symfony\Component\Console\Input\InputInterface;
10-
use Symfony\Component\Console\Output\OutputInterface;
1110
use Symfony\Component\Console\Style\SymfonyStyle;
1211

12+
#[AsCommand(InstallCommand::NAME, 'Guides you through the installation process, to get Shlink up and running')]
1313
class InstallCommand extends Command
1414
{
1515
public const string NAME = 'install';
@@ -19,18 +19,9 @@ public function __construct(private readonly InstallationRunnerInterface $instal
1919
parent::__construct();
2020
}
2121

22-
protected function configure(): void
22+
public function __invoke(SymfonyStyle $io): int
2323
{
24-
$this
25-
->setName(self::NAME)
26-
->setDescription('Guides you through the installation process, to get Shlink up and running.');
27-
}
28-
29-
protected function execute(InputInterface $input, OutputInterface $output): int
30-
{
31-
$io = new SymfonyStyle($input, $output);
3224
$initCommand = $this->getApplication()?->find(InitCommand::NAME);
33-
3425
return $this->installationRunner->runInstallation($initCommand, $io);
3526
}
3627
}

src/Command/UpdateCommand.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Shlinkio\Shlink\Installer\Command;
66

77
use Shlinkio\Shlink\Installer\Service\InstallationRunnerInterface;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
9-
use Symfony\Component\Console\Input\InputInterface;
10-
use Symfony\Component\Console\Output\OutputInterface;
1110
use Symfony\Component\Console\Style\SymfonyStyle;
1211

12+
#[AsCommand(UpdateCommand::NAME, 'Helps you import Shlink\'s config from an older version to a new one')]
1313
class UpdateCommand extends Command
1414
{
1515
public const string NAME = 'update';
@@ -19,18 +19,9 @@ public function __construct(private readonly InstallationRunnerInterface $instal
1919
parent::__construct();
2020
}
2121

22-
protected function configure(): void
22+
public function __invoke(SymfonyStyle $io): int
2323
{
24-
$this
25-
->setName(self::NAME)
26-
->setDescription('Helps you import Shlink\'s config from an older version to a new one.');
27-
}
28-
29-
protected function execute(InputInterface $input, OutputInterface $output): int
30-
{
31-
$io = new SymfonyStyle($input, $output);
3224
$initCommand = $this->getApplication()?->find(InitCommand::NAME);
33-
3425
return $this->installationRunner->runUpdate($initCommand, $io);
3526
}
3627
}

0 commit comments

Comments
 (0)