diff --git a/src/Command/CleanupCommand.php b/src/Command/CleanupCommand.php index fcb0eb5..dd98953 100644 --- a/src/Command/CleanupCommand.php +++ b/src/Command/CleanupCommand.php @@ -8,12 +8,14 @@ use App\Entity\Run; use Doctrine\DBAL\Exception; use App\Repository\RunRepository; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Console\Attribute\AsCommand; 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\HttpKernel\KernelInterface; +#[AsCommand(name: 'webcron:cleanup', description: 'Cleanup runs')] class CleanupCommand extends Command { protected static $defaultName = 'webcron:cleanup'; @@ -30,8 +32,6 @@ class CleanupCommand extends Command protected function configure() { $this - ->setDescription('Cleanup runs') - ->setHelp('This command cleans the runs table') ->addOption('jobid', 'j', InputOption::VALUE_IS_ARRAY + InputOption::VALUE_REQUIRED, 'The ids of the jobs to clean') ->addOption('maxage', 'm', InputOption::VALUE_REQUIRED, 'The maximum age of the oldest runs'); } diff --git a/src/Command/DaemonCommand.php b/src/Command/DaemonCommand.php index 857e338..d36a161 100644 --- a/src/Command/DaemonCommand.php +++ b/src/Command/DaemonCommand.php @@ -6,17 +6,16 @@ namespace App\Command; use App\Entity\Job; use App\Repository\JobRepository; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Console\Attribute\AsCommand; 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\HttpKernel\KernelInterface; - +#[AsCommand(name: 'webcron:daemon', description: 'The master script of Webcron Management')] class DaemonCommand extends Command { - - protected static $defaultName = 'webcron:daemon'; protected $kernel; protected $doctrine; @@ -31,7 +30,6 @@ class DaemonCommand extends Command protected function configure() { $this - ->setDescription('The deamon slayer of webcron') ->setHelp('This command is the daemon process of webcron, enabling webcron to actually run jobs on time') ->addOption('time-limit', 't', InputOption::VALUE_REQUIRED, 'Time limit in seconds before stopping the daemon.') ->addOption('async', 'a', InputOption::VALUE_NEGATABLE, 'Time limit in seconds before stopping the daemon.'); diff --git a/src/Command/DemoInstallCommand.php b/src/Command/DemoInstallCommand.php index d0df284..a0e1e99 100755 --- a/src/Command/DemoInstallCommand.php +++ b/src/Command/DemoInstallCommand.php @@ -8,6 +8,7 @@ use App\Entity\User; use App\Repository\RunRepository; use Doctrine\DBAL\Connection; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,9 +16,9 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; +#[AsCommand(name: 'webcron:demodata', description: 'Install demo data')] class DemoInstallCommand extends Command { - protected static $defaultName = 'webcron:demodata'; protected $kernel; protected $doctrine; protected $passwordHasher; @@ -33,7 +34,6 @@ class DemoInstallCommand extends Command protected function configure() { $this - ->setDescription('Install demo data') ->setHelp('This command installs the demo data'); } diff --git a/src/Command/MailFailedRunsCommand.php b/src/Command/MailFailedRunsCommand.php index a5ad886..e9210c9 100644 --- a/src/Command/MailFailedRunsCommand.php +++ b/src/Command/MailFailedRunsCommand.php @@ -7,6 +7,7 @@ use App\Entity\User; use App\Repository\JobRepository; use App\Repository\UserRepository; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -19,9 +20,9 @@ use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Email; use Twig\Environment; +#[AsCommand(name: 'webcron:mail-failed-runs', description: 'Sends email about failed runs')] class MailFailedRunsCommand extends Command { - protected static $defaultName = 'webcron:mail-failed-runs'; protected $kernel; protected $doctrine; protected $templating; @@ -39,7 +40,6 @@ class MailFailedRunsCommand extends Command protected function configure() { $this - ->setDescription('Sends email about failed runs') ->setHelp('This command will send emails to the users when jobs are failing') ->addArgument('recipients', InputArgument::REQUIRED + InputArgument::IS_ARRAY, 'Which e-mailaddress should receive the notifications'); } diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index 1bd3fa6..e124aa7 100755 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -4,15 +4,16 @@ namespace App\Command; use App\Entity\Job; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\KernelInterface; +#[AsCommand(name: 'webcron:run', description: 'Run a single cronjob')] class RunCommand extends Command { - protected static $defaultName = 'webcron:run'; protected $kernel; protected $doctrine; @@ -26,7 +27,6 @@ class RunCommand extends Command protected function configure() { $this - ->setDescription('Run a single cronjob') ->setHelp('This command runs a single command') ->addArgument('jobid', InputArgument::REQUIRED, 'The id of the job to be run'); } diff --git a/src/Command/UserCommand.php b/src/Command/UserCommand.php index 59d891d..6123a44 100755 --- a/src/Command/UserCommand.php +++ b/src/Command/UserCommand.php @@ -8,6 +8,7 @@ use App\Entity\User; use App\Repository\RunRepository; use Doctrine\DBAL\Connection; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; @@ -21,6 +22,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; +#[AsCommand(name: 'webcron:user', description: 'User stuff')] class UserCommand extends Command { protected static $defaultName = 'webcron:user'; @@ -48,7 +50,6 @@ class UserCommand extends Command protected function configure() { $this - ->setDescription('User stuff') ->setHelp('The command is doing user stuff') ->addArgument('action', InputArgument::REQUIRED, 'What action should be executed? [add, delete, update]', null, ['add', 'update', 'delete']) ->addOption('username', 'u', InputOption::VALUE_OPTIONAL, 'What action should be executed? [add, delete, update]', '')