diff --git a/composer.json b/composer.json index 9a9684a..3a78973 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ }, "autoload": { "psr-4": { - "Seacms\\ComposerInstaller\\": "src" + "Seacms\\ComposerInstaller\\": "src/installer/", + "Seacms\\Command\\": "src/commands/" } }, "extra": { diff --git a/src/commands/Command.php b/src/commands/Command.php new file mode 100644 index 0000000..fc3e633 --- /dev/null +++ b/src/commands/Command.php @@ -0,0 +1,63 @@ +setName('seacms-test'); + + $this + // the short description shown while running "php bin/console list" + ->setDescription('Testing seacms from command line') + + // 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") + + ->addOption('toto', '', InputOption::VALUE_NONE, 'Display toto text') + ->addOption('text', 't', InputOption::VALUE_REQUIRED, 'Display the text') + ; + } + + + /** + * execute the command + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('Testing seacms'); + + $totoOption = $input->getOption('toto'); + $textOption = $input->getOption('test'); + + if ($totoOption){ + $output->writeln('toto'); + } + if ($textOption){ + $output->writeln($textOption); + } + return Command::SUCCESS; + } +} \ No newline at end of file diff --git a/src/Handler.php b/src/installer/Handler.php similarity index 100% rename from src/Handler.php rename to src/installer/Handler.php diff --git a/src/NotFoundFileException.php b/src/installer/NotFoundFileException.php similarity index 100% rename from src/NotFoundFileException.php rename to src/installer/NotFoundFileException.php diff --git a/src/ParentPlugin.php b/src/installer/ParentPlugin.php similarity index 86% rename from src/ParentPlugin.php rename to src/installer/ParentPlugin.php index 629e5ae..02f528b 100644 --- a/src/ParentPlugin.php +++ b/src/installer/ParentPlugin.php @@ -9,11 +9,12 @@ namespace Seacms\ComposerInstaller; use Composer\Composer; use Composer\IO\IOInterface; +use Composer\Plugin\Capable; use Composer\Plugin\PluginInterface; use TopFloor\ComposerCleanupVcsDirs\Plugin as TopFloorPlugin; if (class_exists(TopFloorPlugin::class,true)){ - abstract class ParentPlugin extends TopFloorPlugin + abstract class ParentPlugin extends TopFloorPlugin implements Capable { /** * const to test if TopFloorPlugin @@ -22,7 +23,7 @@ if (class_exists(TopFloorPlugin::class,true)){ protected const IS_TOP_FLOOR_PLUGIN = true; } } else { - abstract class ParentPlugin implements PluginInterface + abstract class ParentPlugin implements PluginInterface, Capable { /** diff --git a/src/Plugin.php b/src/installer/Plugin.php similarity index 97% rename from src/Plugin.php rename to src/installer/Plugin.php index bb999be..8ae1988 100644 --- a/src/Plugin.php +++ b/src/installer/Plugin.php @@ -215,4 +215,12 @@ class Plugin extends ParentPlugin } throw new Exception("Correspondance not found"); } + + /* === implements Capable === */ + public function getCapabilities() + { + return [ + 'Composer\Plugin\Capability\CommandProvider' => 'Seacms\\Command\\Command', + ]; + } } \ No newline at end of file