From bb11cec5c713b28349605f7cae3babb08833fdd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?= Date: Sun, 19 Mar 2023 10:21:43 +0100 Subject: [PATCH] fix(CommandProvider): use it --- src/commands/{SeacmsTest.php => Command.php} | 24 ++++--------------- src/commands/CommandProvider.php | 25 ++++++++++++++++++++ src/installer/Plugin.php | 2 +- 3 files changed, 31 insertions(+), 20 deletions(-) rename src/commands/{SeacmsTest.php => Command.php} (71%) create mode 100644 src/commands/CommandProvider.php diff --git a/src/commands/SeacmsTest.php b/src/commands/Command.php similarity index 71% rename from src/commands/SeacmsTest.php rename to src/commands/Command.php index 935bbd6..594d948 100644 --- a/src/commands/SeacmsTest.php +++ b/src/commands/Command.php @@ -9,29 +9,15 @@ namespace Seacms\Command; use Composer\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** * Command to lauch tests from command line accross all seacms dependencies */ - class SeacmsTest extends BaseCommand + class Command extends BaseCommand { - /** - * @var string|null The default command name - */ - protected static $defaultName = 'seacms-test'; - - /** - * overwrite default __construct to be abel to receive array - * @param array|string|null $args - */ - public function __construct(string $name = null) - { - $name = is_string($args) ? $args : null; - parent::__construct($name); - } - /** * set name */ @@ -44,8 +30,8 @@ use Symfony\Component\Console\Output\OutputInterface; // the full command description shown when running the command with // the "--help" option - // ->setHelp("Test seacms via command line.\n". - // "(Only if phpunit available)\n") + ->setHelp("Test seacms via command line.\n". + "(Only if phpunit available)\n") ->addOption('toto', '', InputOption::VALUE_NONE, 'Display toto text') ->addOption('text', 't', InputOption::VALUE_REQUIRED, 'Display the text') @@ -64,7 +50,7 @@ use Symfony\Component\Console\Output\OutputInterface; $output->writeln('Testing seacms'); $totoOption = $input->getOption('toto'); - $textOption = $input->getOption('test'); + $textOption = $input->getOption('text'); if ($totoOption){ $output->writeln('toto'); diff --git a/src/commands/CommandProvider.php b/src/commands/CommandProvider.php new file mode 100644 index 0000000..ce10137 --- /dev/null +++ b/src/commands/CommandProvider.php @@ -0,0 +1,25 @@ + 'Seacms\\Command\\SeacmsTest', + 'Composer\Plugin\Capability\CommandProvider' => 'Seacms\\Command\\CommandProvider', ]; } /* === implements EventsSubscriberInterface === */